2017-04-19 18 views
4

私はABAQUS/Viewerの結果から3D pdfを印刷する方法を探しています。これにより、シミュレーションの結果に興味があるがABAQUSにアクセスできない他の人と結果を簡単に伝えることができます。ABAQUS/Viewerから3D PDFを印刷するには?

答えて

6

vrmlファイルをエクスポートし、Tetra4Dまたはpdf3DとAdobe Acrobat Professionalを使用して変換することをお勧めします。 3Dのpdfは非常によく見える。しかし、商用ソフトウェアは年間800ポンド以上の費用がかかります。私は、U3Dファイルを作成するためのMeshlab(http://www.meshlab.net/)、U3Dファイルを作成するためのMiKTeX(https://miktex.org/)、2つのオープンソースツールを使用するAbaqus/CAE & Viewerから3D pdfを直接作成するPythonスクリプトを作成しました。 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 
+0

私はあなたのソリューションを試してみて、それが機能することを確認しました。結果に非常に満足しています。 ありがとうございます! – CodeCupboard

+1

@churchwalkあなたが満足してうれしいです。私は、AbaqusViewerの輪郭を描いたエクスポートでシェーディングを使用する方法を見つけることができませんでした。しかし、それはまだかなり良いように見えます。 – DougR

+0

興味深いことに、この方法を使ってパワーポイントプレゼンテーションに3D画像を作成できますか? – CodeCupboard

1

のAbaqus * .ODB結果を印刷する最も簡単な方法は、Abaqusの* .ODBファイルを読み込まれ、あなたが任意の解像度を持つ*。TIFと* .pngの結果を得ることができ、あなたができるのTecplot 360を使用しています3Dでモデルを回転させ、必要なフォントやすべてのものを変更します。

関連する問題