How to convert an uploaded STEP file to other formats?

痴心易碎 提交于 2019-12-17 19:53:31

问题


How can I convert an uploaded STEP file to other CAD formats? Preferably using PHP.

I uploaded a small STEP file to 3dContentCentral and was instantly presented with 20 different filetype formats of my newly uploaded STEP file. Example url: http://www.3dcontentcentral.com/Download-Model.aspx?catalogid=171&id=584767

Hope some of you can point me in the right direction :)


回答1:


You can use the API provided by FreeCAD to convert a STEP file to different 3D format.

The API is written with Python, but you can use Pip - Python in PHP

Here is an example that shows how to convert a file from STEP to OBJ format using python:

import os
import ImportGui
files = os.listdir("path")
for file in files:
    ImportGui.open("path" + file)
    App.setActiveDocument("Unnamed")
    App.ActiveDocument=App.getDocument("Unnamed")
    Gui.ActiveDocument=Gui.getDocument("Unnamed")
    Gui.SendMsgToActiveView("ViewFit")
    __objs__=[]
    __objs__.append(FreeCAD.getDocument("Unnamed").getObject("Part__Feature"))
    index = 1
    base = 'Part__Feature00'
    while FreeCAD.getDocument("Unnamed").getObject(base + str(index)) is not None:
        __objs__.append(FreeCAD.getDocument("Unnamed").getObject(base + str(index)))
        index+=1

    import Mesh
    Mesh.export(__objs__,"path" + file + ".obj")
    del __objs__
    App.closeDocument("Unnamed")


来源:https://stackoverflow.com/questions/29865401/how-to-convert-an-uploaded-step-file-to-other-formats

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!