What's new

Script Release: STL Import

NateLiqGrav

Alibre Super User
upload_2020-4-20_23-18-5.png

This script uses the open source stltostp to convert the STL file to an STP file and then optionally import it into Alibre.
You must download and install stltostp before running.
https://github.com/slugdev/stltostp

If you installed stltostp but the script can't find it then you will need to correct the path in the code:
Code:
path_to_stltostp_exe = r'C:\Program Files\stltostp\1.0\bin\stltostp.exe'
If the script says "Took too long. I stopped waiting." then you will need to extend the max time in the code:
Code:
MaxWaitTime = 100 #number of seconds to wait for the conversion to finish

Please post here about any issues or suggestions. Also let me know if you use it and like it or even if you don't.

[edit]
Added new version with more error checking.
'STL Import.py' was downloaded 21 times before being replaced by 'STL Import3.py'
[/edit]
 

Attachments

  • STL Import3.py
    3.4 KB · Views: 51
Last edited:

NateLiqGrav

Alibre Super User
Hello Matthew,
Per the creator of the stltostp.exe file - it is a Command line utility.

It does not have a graphical user interface. Meaning you can only run it manually from the Windows Command Prompt or using another script/program. That is why I made this Alibre Script to run it.
 

TimoCAD

Senior Member
What about letting the User pass the Installation path of 'stltostp' to the program at first start? Suggestion!

Great work thumbs up!
 

anson

Member
Im having trouble getting it to work. I just get this error:
Code:
>>>
0 seconds waiting for conversion
Done!
C:\Users\Dell T3500\Downloads\stltostp-master\stltostp-master\test\bucket.stp
Encounter problem importing.
Exiting.
>>>
 

NateLiqGrav

Alibre Super User
Im having trouble getting it to work. I just get this error:
Code:
>>>
0 seconds waiting for conversion
Done!
C:\Users\Dell T3500\Downloads\stltostp-master\stltostp-master\test\bucket.stp
Encounter problem importing.
Exiting.
>>>
This usually means something was wrong with the STL format. Can you upload the STL file for testing?
 

NateLiqGrav

Alibre Super User
I had no problem with the bucket.stl or any STL file from there.
I have added more error checking to let the user know if something was entered wrong.
Try downloading the new version of my script and bucket.stl file again and trying again.
 

anson

Member
I gave it three more tries this morning.
Code:
>>>
  File "", line 83
                except

                      ^
SyntaxError: unexpected token '<newline>'

>>>
Then I added a colon at the end of line 83
Code:
>>>
0 seconds waiting for conversion to finish.
Unknown parameter C:\Users\Dell
Opening STP file.
Encounter problem importing.
Exiting.
>>>
This appears to be a space in file path problem so I put quotes around the path
Code:
>>>
Wrong extension for STL Input File.
Exiting.
>>>
Thanks for all your help. What else do you suggest I should try?
 

NateLiqGrav

Alibre Super User
Ok, I see whats going on now.
I accidentally deleted the colon when I deleted a console print just below it. I have fixed that.
The other issue is that paths with spaces needed to be wrapped in double quotes - but only at the time they are passed to stltostp. Thank you for helping me pinpoint that issue. Please try the new upload.
 

CADNoob

New Member
Ok, I see whats going on now.
I accidentally deleted the colon when I deleted a console print just below it. I have fixed that.
The other issue is that paths with spaces needed to be wrapped in double quotes - but only at the time they are passed to stltostp. Thank you for helping me pinpoint that issue. Please try the new upload.

I am having the following issue when I try and run the script, it seeems to work but this is the output from the console:

0 seconds waiting for conversion to finish.
Minimum edge tolerance set to 1e-06 Read 88 triangles from C:\Users\mitch\OneDrive\Desktop\Ender3\Files\STL\HEX Remote Test Box Connector Wedge.stl Merged 132 edges Exported STEP file: C:\Users\mitch\OneDrive\Desktop\Ender3\Files\STEP\HEX Remote Test Box Connector Wedge.stp
Output File Not Found

There is no *.stp file yet I thought that this script would create that
 

NateLiqGrav

Alibre Super User
C:\Users\mitch\OneDrive\Desktop\Ender3\Files\STEP\HEX Remote Test Box Connector Wedge.stp
I noticed that the paths are different. Can you confirm that the STEP folder path exists before it tries to export it? I'm guessing it doesn't. If the folder structure does not exist it does not currently create it automatically.
 

CADNoob

New Member
I noticed that the paths are different. Can you confirm that the STEP folder path exists before it tries to export it? I'm guessing it doesn't. If the folder structure does not exist it does not currently create it automatically.

Thanks for getting back to me, yes the paths are different in the files folder I have 2 sub-folders STL ( where the input files are) and STEP (where I want the converted files to be placed.
 

CADNoob

New Member
Thanks for getting back to me, yes the paths are different in the files folder I have 2 sub-folders STL ( where the input files are) and STEP (where I want the converted files to be placed.

I moved the stl file to the root C:\ file.stl Then enterd this in the pop up:
STL Input file: C:\file.stl
STP Output File: C:\file.stp

I unchecked Open In Alibre after Output? This is what was in the console:

0 seconds waiting for conversion to finish.
Minimum edge tolerance set to 1e-06 Read 88 triangles from C:\file.stl Merged 132 edges Exported STEP file: C:\file.stp

Now the problem is there is no file.stp although the script claims to have exported it...

Have any clue?
 

CADNoob

New Member
I moved the stl file to the root C:\ file.stl Then enterd this in the pop up:
STL Input file: C:\file.stl
STP Output File: C:\file.stp

I unchecked Open In Alibre after Output? This is what was in the console:

0 seconds waiting for conversion to finish.
Minimum edge tolerance set to 1e-06 Read 88 triangles from C:\file.stl Merged 132 edges Exported STEP file: C:\file.stp

Now the problem is there is no file.stp although the script claims to have exported it...

Have any clue?


I have investigated further. I ran just the converter stltostp in the command line and get the same results, I can not find the step file?
 

NateLiqGrav

Alibre Super User
I have investigated further. I ran just the converter stltostp in the command line and get the same results, I can not find the step file?
I'm afraid I don't know. I didn't make the original stltostp command line program. I just wrapped it in an Alibre Script for convenience and added features. Perhaps try another program to see if it has issues with that stl file?
 

srjacob

Senior Member
I tried to STLtoSTP as a standalone program, and it didn't work for the stl files I downloaded. It said that I couldn't find any triangle, but FreeCad converted the file. Unfortunately, the converted file was too big and Alibre choked on it.

Any good conversion advice would be appreciated.
 

bigseb

Alibre Super User
From another thread:

... The biggest downfall here (in my opinion) is AD. AD isn't the greatest at importing faulty files so the slightest surface mismatch and you have an unusable file. Moi to the rescue. Also AD doesn't seem to handle organic shapes very well so you often up with really weird surfaces.
 
Top