如何从ABAQUS / Viewer打印3D pdf?

时间:2017-04-19 14:05:57

标签: pdf 3d abaqus

我正在寻找一种从结果ABAQUS / Viewer中打印3D pdf的方法。这样可以轻松地将结果与对仿真结果感兴趣但无法访问ABAQUS的其他人进行通信。

2 个答案:

答案 0 :(得分:6)

最好的方法是导出vrml文件并使用Tetra4D或pdf3D和Adobe Acrobat professional进行转换。 3D pdf看起来非常好。但是,商业软件每年的成本将超过800英镑。我确实创建了一个Python脚本来直接从Abaqus / CAE& amp;创建一个3D pdf。使用2个开源工具的Viewer:1)Meshlab(http://www.meshlab.net/)创建U3D文件,2)MiKTeX(https://miktex.org/)将U3D文件转换为pdf。输出不如Tetra4D那么精致,但它有效。我没有尝试使用最新版本的Meshlab。只需从Abaqus / CAE或Abaqus / Viewer运行此脚本。

# Abaqus CAE/Viewer Python Script to create a 3D pdf directly from Abaqus/CAE or Abaqus/Viewer.
# You must first install meshlab (meshlabserver.exe)and MiKTeX (pdflatex.exe)
# Edit this script to reflect the installed locations of meshlabserver.exe and pdflatex.exe
# It will export a stl or obj  file the mesh of current viewport and convert into 3D pdf
# Or run in Abaqus/viewer and it will create a VRML file and convert to 3D pdf.
# If contours are displayed in Abaqus Viewer, then it will create a contour 3D pdf

from abaqus import *
from abaqusConstants import *
from viewerModules import *
import os
import subprocess
import sys

# -----------------------------------------------------------------------------
pdfName='try' 
meshlab_path="C:/Program Files/VCG/MeshLab/meshlabserver.exe"
pdfLatex_path="C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/pdflatex.exe"
# -----------------------------------------------------------------------------

currView=session.viewports[session.currentViewportName]
try:  # for Abaqus Viewer
    cOdbD=currView.odbDisplay
    odb = session.odbs[cOdbD.name]    
    name=odb.name.split(r'/')[-1].replace('.odb','')
    module='Vis'
except: # Abaqus CAE
    #name=currView.displayedObject.modelName
    import stlExport_kernel
    name = repr(currView.displayedObject).split('[')[-1].split(']')[0][1:-1] # allows for either main or visulation modules
    module='CAE'

print module

if module=='CAE':
    #All instances must be meshed    
    cOdbD=None
    try:
        ext='.stl'
        stlExport_kernel.STLExport(moduleName='Assembly', stlFileName=pdfName + ext, stlFileType='BINARY')
    except:
        try:
            ext='.obj'
            session.writeOBJFile(fileName=os.path.join(directory,pdfName + ext), canvasObjects= (currView, ))
        except:
            print 'Either your assembly is not fully meshed or something else'       
    directory=(os.getcwd())
else:  # Abaqus/Viewer
    if cOdbD.viewCut: 
        session.graphicsOptions.setValues(antiAlias=OFF) # Better with anti aliasing off
    odb = session.odbs[cOdbD.name]    
    directory=odb.path.replace(odb.path.split('/')[-1],'').replace('/','\\')    
    # Turn off most of the stuff in the viewport
    currView.viewportAnnotationOptions.setValues(triad=OFF, 
        legend=OFF, title=OFF, state=OFF, annotations=OFF, compass=OFF)
    ext='.wrl'
    session.writeVrmlFile(fileName=os.path.join(directory,pdfName + ext),  
        compression=0, canvasObjects= (currView, ))

pdfFilePath=os.path.join(directory,pdfName+'-out.pdf')
if os.path.isfile(pdfFilePath):
    os.remove(pdfFilePath)
    #Check file was deleted
    if os.path.isfile(pdfFilePath):    
        print "Aborted because pdf file of same name cant be deleted. Please close programs which it might be open in"
        1/0  #a dodgy way to exit program

# Invoke meshlab to convert to a .u3d file        
if cOdbD:  #If in Abaqus/viewer
    if 'CONTOURS' in repr(cOdbD.display.plotState[0]):    # If contours are displayed. Output contoured pdf
        p=subprocess.Popen([meshlab_path,'-i',pdfName + ext, '-o',pdfName + '.u3d','-m','vc'])  #'vn fn fc vt'
    else:
        p=subprocess.Popen([meshlab_path,'-i',pdfName + ext, '-o',pdfName + '.u3d'])
else:
    p=subprocess.Popen([meshlab_path,'-i',pdfName + ext, '-o',pdfName + '.u3d'])    

p.communicate()   # Wait for meshlab to finish

file_fullPathName=os.path.join(directory, pdfName + '.tex') 

#Read the .tex file which meshlab has just created
with open(file_fullPathName, 'r') as texFile:
    lines = texFile.read()

#Edit the .tex file    
lines=lines.replace("\usepackage[3D]{movie15}","\\usepackage[3D]{movie15}\n\\usepackage[margin=-2.2in]{geometry}")
if cOdbD:
    if 'CONTOURS' in repr(cOdbD.display.plotState[0]):
        lines=lines.replace("3Dlights=CAD,","3Dlights=CAD,\n\t3Drender=SolidWireframe,")
lines=lines.replace("\n\end{document}","{---------------------------------------------------------------------------------Click above!  MB1 - rotate,  MB2 wheel or MB3 - zoom, Ctrl-MB1 - pan--------------}\n\\end{document}")

file_fullPathName=os.path.join(directory, pdfName + '-out.tex') 
with open(file_fullPathName, "w") as outp:
    outp.write(lines) 

p=subprocess.Popen([
    pdfLatex_path,
    pdfName + '-out.tex',
    ])

p.communicate()
print 'Conversion to pdf complete'
print file_fullPathName

答案 1 :(得分:1)

打印Abaqus * .odb结果的最简单方法是使用Tecplot 360读取Abaqus * .odb文件,你可以获得任何分辨率的* .tif和* .png结果,你也可以旋转模型在3D中并更改字体和所需的所有内容。