syclone

[HELP] stl to dat conversion

Recommended Posts

Good Day.

Started using LDcad recently to make instructions, but need a custom part to complete a project (the new Technic 49.5x14 tyre from upcoming Creator pickup and VW van). I have modified a 49.5x20 tyre to a 14mm width in Blender and exported as .stl (in mm, then exported into LDD to test and it is the perfect size).

Now when it came to making a dat, I ran into some issues:

https://github.com/HazenBabcock/stl-to-dat Partially worked, but it output an empty dat file like this:

0 input_file.dat

0 !LDRAW Unofficial_part

0 BFC CERTIFY CCW

And Python IDLE writes this error:

Traceback (most recent call last):
  File "D:\lego\stl2ldraw\stl2ldcad.py", line 30, in <module>
    for line in fp_in:
  File "C:\Users\Moroz\AppData\Local\Programs\Python\Python39\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 563: character maps to <undefined>
>>> 

- https://gist.github.com/johnholbrook/3db07cda9e267ea6ee53b443588df44c I think I started it correctly, but it did not produce any results at all.

- http://marc.klein.free.fr/lego/stl2dat/stl2dat.html I honesty lack the knowledge to make this work.

- As last resort, tried Stud.io part designer, which first wanted me to install Stud.io (why???), which I did, but then it refused to properly start up, getting stuck on "parsing file" screen, despite various reinstalls and computer restarts.

Are there any other tools that I missed out there? Frankly speaking, I'm inept at any sort of programming and simple command line interactions,  even executing a python file has been a challenge for me, so perhaps I'm just commiting an error somewhere?

If anyone could help in, or convert the file, I would really appreciate it. The modified .stl: download

Edited by syclone

Share this post


Link to post
Share on other sites

In the video, he talks about making .stl files in LDRAW and converting .stl back to .dat, which I believe is what you want to do.

 

Share this post


Link to post
Share on other sites
18 minutes ago, 1963maniac said:

In the video, he talks about making .stl files in LDRAW and converting .stl back to .dat, which I believe is what you want to do.

Thanks for such an interesting video.

Seems that he is using the same github code from my first try - will have to dig deeper into python and solve that random error then. 

Share this post


Link to post
Share on other sites

Are you using an ascii (human readable) stl file?

If so be sure it's encoded as utf8 and not using some windows codepage.

The python error is about an invalid unicode character, which is what happens if you try to use a non utf8 file containing 'weird' (e.g ß etc) characters like it is utf8.

 

Share this post


Link to post
Share on other sites
34 minutes ago, roland said:

Are you using an ascii (human readable) stl file?

If so be sure it's encoded as utf8 and not using some windows codepage.

The python error is about an invalid unicode character, which is what happens if you try to use a non utf8 file containing 'weird' (e.g ß etc) characters like it is utf8.

Thank You so much!!! Indeed, turns out my stl file was a binary one, converted to ASCII and it all worked flawlessly! Didn't even know there were different types of .stl :oh3:

Here's the result, the .dat as well if anyone needs it: download

input1.png

Thank You once again! 

Edited by syclone

Share this post


Link to post
Share on other sites

I'm now trying to also convert stl files to dat. I'm trying to understand what you did that was successful.

I made a custom Lego compatible gear with with gear-v3.scad from thingyverse which is an .stl file. Now I want it to become a .dat file. 

What did you use to covert to .dat? and then you used  converted to ASCII ? Sorry, I'm a novice at this.

Share this post


Link to post
Share on other sites
1 hour ago, 1963maniac said:

I'm now trying to also convert stl files to dat. I'm trying to understand what you did that was successful.

I made a custom Lego compatible gear with with gear-v3.scad from thingyverse which is an .stl file. Now I want it to become a .dat file. 

What did you use to covert to .dat? and then you used  converted to ASCII ? Sorry, I'm a novice at this.

Yes, I ended up succesful)))

- converted my binary .stl file to ascii-encoded .stl using this website tool: https://www.meshconvert.com/ 
- used this tool to convert the resulting stl into .dat: https://github.com/HazenBabcock/stl-to-dat

The .dat converter is a python program, I used Python IDLE, opening the file there, then "Run" > "Run Customised" (or Shift+F5) Then in the command box that opens wrote the input file name (with the .stl extension). The .py program and the input file must be in the same folder, the output .dat will be generated with same name as input file in that folder too. Then I've placed mine into the unofficial library, re-run the indexing executable and was able to use the part.

-----------------------------------------------------------

Although I've run into another small issue:

When editing in LDCad, the part is invisible, only can see a crosshair marking the part position (it can be edited and placed that way). The part does show up in LDView,POVRay and LDpub though, so instructions and renders are unaffected. Have no idea why this happens.

Share this post


Link to post
Share on other sites
4 hours ago, syclone said:

When editing in LDCad, the part is invisible, only can see a crosshair marking the part position (it can be edited and placed that way). The part does show up in LDView,POVRay and LDpub though, so instructions and renders are unaffected. Have no idea why this happens.

Is it a yellow or red crosshair?

If yellor it means a render preparation error, in which case I would be interested in the .dat file used.

If red it means it couldn't find the referenced part. In that case make sure it is findable by placing it in the same folder as the model using it or in a parts folder of a known library location.

Share this post


Link to post
Share on other sites
15 minutes ago, roland said:

Is it a yellow or red crosshair?

If yellor it means a render preparation error, in which case I would be interested in the .dat file used.

If red it means it couldn't find the referenced part. In that case make sure it is findable by placing it in the same folder as the model using it or in a parts folder of a known library location.

It was a red one, placing the .dat in the model's location fixed it, thank you so much!! 

mpdfile.png

Share this post


Link to post
Share on other sites
On 8/6/2021 at 11:18 AM, syclone said:

Yes, I ended up succesful)))

- converted my binary .stl file to ascii-encoded .stl using this website tool: https://www.meshconvert.com/ 
- used this tool to convert the resulting stl into .dat: https://github.com/HazenBabcock/stl-to-dat

The .dat converter is a python program, I used Python IDLE, opening the file there, then "Run" > "Run Customised" (or Shift+F5) Then in the command box that opens wrote the input file name (with the .stl extension). The .py program and the input file must be in the same folder, the output .dat will be generated with same name as input file in that folder too. Then I've placed mine into the unofficial library, re-run the indexing executable and was able to use the part.

-----------------------------------------------------------

Although I've run into another small issue:

When editing in LDCad, the part is invisible, only can see a crosshair marking the part position (it can be edited and placed that way). The part does show up in LDView,POVRay and LDpub though, so instructions and renders are unaffected. Have no idea why this happens.

I'm kind of stuck. I had https://www.meshconvert.com/ convert my file to ascii. I just don't know enough about this to be successful. My son is printing some roller coaster track and I would really like to be able to use this part in my track layouts. I downloaded https://github.com/HazenBabcock/stl-to-dat . Does the Hazen Babcock converter have to be used within a "Py" program? Would someone be kind enough to help me get my file converted to .dat? I would be forever grateful!! 

Share this post


Link to post
Share on other sites
10 hours ago, 1963maniac said:

I'm kind of stuck. I had https://www.meshconvert.com/ convert my file to ascii. I just don't know enough about this to be successful. My son is printing some roller coaster track and I would really like to be able to use this part in my track layouts. I downloaded https://github.com/HazenBabcock/stl-to-dat . Does the Hazen Babcock converter have to be used within a "Py" program? Would someone be kind enough to help me get my file converted to .dat? I would be forever grateful!! 

Yes, his program has to be used via Python: https://www.python.org/downloads/ 

Though I can convert these to .dat for you, you can send the files through PM if you need :thumbup:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.