hexagon logo

STL creation in python api

Hello ,

 Can we create a .stl file in Simufact python API using .stl creation code just like we do in MATLAB? 

I have tried but the system was showing this errors: 

ModuleNotFoundError: No module named 'stl'

Thanks,

VIgnesh

  • Hello Vignesh,

    Yes, you can use Simufact python API to create .stl files, for that you have to install the required package before with "pip" Python package installer. 

    Please find instruction of the "pip" usage in the documentation linked in the python terminal by searching for "pip":

    Best regards,

    Qi

  • Hello I have followed the instructions but couldn't install the PIP. 

    Traceback (most recent call last):

    File "<string>", line 1, in <module>

    File "<string>", line 2, in <module>

    ModuleNotFoundError: No module named 'stl'

    is there any other way to install the 3rd party packages.

  • I have few other questions related to python script. 

    1. I am trying to generate random preforms .stl files based on 3D revolution across y-axis using 2D control points, is it possible to do it in Simufact python module since i have been getting this errors. ( i was successfully able to generate them in MATLAB, if its not possible to do it in Simufact python, can i call the MATLAB script to run and generate those files which can be assigned in to Simufact project?) 

    2. can we integrate the strain results of the generated preform obtained from the .stl files from step 1, to generate new .stl files using customizes algorithm based on strain constraints at preferred locations. 

    3. If I have 10 preforms, can I run all 10 preforms simulations at a time which can auto assign themselves to the dies and generate results? 

    Thanks,

    Vignesh. 

  • I was able to create the 3rd party package using PIP one problem is solved!! It would be helpful if I could get the answers for my other questions. 

  • Hi Vignesh,

    I'm happy to hear that you were able to install the package using pip. In this case you should be able to generate random .stl files as you did in MATLAB, and you can then directly import the generated .stl file into Simufact project via python. I assumed your first question is answered or solved.

    To your second question: Yes, it is possible to extract results by accessing object Project -> Process -> Results -> ResultIncrement -> Mesh -> IntegrationPointResults or NodeResults. Please search for the class name in the same documentation for instruction. The results can e.g. be exported into a file for further data processing.

    To the third question: Yes, you can setup the model, export the results, run your own algorithm to generate new .stl and assign them again in a loop so that e.g. 10 simulations can be started one after another and run at a time. But please note how many simulations can be performed at a time is limited by your available licenses and hardware (processors).

  • Hi,

    I’m having an issue with my PIP installation. Could you help me by sharing how you installed it?

    kamar 

  • Hi Kamar,

    I can gladly help you with the question. 

    First the pip installer is located in your Simufact product installation directory, e.g. for Forming it is by default C:\Program Files\simufact\forming\<version>\sfForming\python. You can open a prompt there and run the installer as followed: 

    pip.bat install somepackage

    If you would like to distinguish between a system-wide and a user-wide installation, please refer to our document C:\Program Files\simufact\forming\<version>\doc\Scripting\thirdparty.html for more information.

    Just let me know if this works for you or you have further questions!

  • Hi,

    Thank you very much for your help! I was able to follow your instructions and successfully complete the installation.

    Best regards,
    Kamar