4

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 :)

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
Kenneth Poulsen
  • 929
  • 10
  • 25
  • Same with Tracepartsonline.net (download menu in right side of page). Example: http://www.tracepartsonline.net/(S(fwm1mzdh541b45rnntkwdnzb))/PartDetails.aspx?Class=DIN&clsid=&ManID=DIN&PartFamilyID=10-17072008-106652&PartID=10-17072008-106652&sk_Reference=Bolt+DIN+7964+-+d+M8+x+l+25+-+KC+-+K+-+H&SrchRsltId=1&SrchRsltType=4 – Kenneth Poulsen Apr 25 '15 at 15:42
  • Hello Kenneth. Were you able to solve this problem? I am working on a project in which I have to convert an uploaded STEP file into different file types and was wondering if you could point me in the right direction of how you accomplished this. – Umar Dastgir Apr 22 '19 at 15:48
  • Would be nice to have some progress to do this.. I cannot imagine that nobody already realized? Theoretically it should be well for performance to read each line in a database and not to read the whole file at once.. – rokdd Apr 30 '19 at 09:29

1 Answers1

4

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")
Ayoub Falah
  • 484
  • 3
  • 19