import stl format file into yade

Asked by gaoxuesong

We can use the ymport.stl function to import facet from stl format file.
I want to ask if the coding of the file must be binary or not?
In my case, i need to do some modifications to the geometry, such as move and scale.
So first i save my geometry to stl file using ASCii coding and open it with python, like 'fd=open(stlfile, 'r')', then i can do some modifications. After that, i save the file in the ascii coding too. In order to import it into Yade, i use the paraview to change the coding of the stl file from ascii to binary.
It is so fussy. Could anyone give me some advice?

Thanks,
Xuesong

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
gaoxuesong
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

yade can open plain text stl files. I have just tried it, it works with recent development version, but DOES NOT work for 2018.02b
###
lines = (
   "solid test",
      "facet normal 1 0 0",
         "outer loop",
            "vertex 0 0 0",
            "vertex 0 1 0",
            "vertex 0 0 1",
         "endloop",
      "endfacet",
      "facet normal 0 0 1",
         "outer loop",
            "vertex 0 0 0",
            "vertex 0 1 0",
            "vertex 1 0 0",
         "endloop",
      "endfacet",
   "endsolid test",
)
with open("test.stl","w") as f:
   f.writelines(l+"\n" for l in lines)

from yade import ymport
facets = ymport.stl("test.stl")
O.bodies.append(facets)
###

cheers
Jan

Revision history for this message
gaoxuesong (260582472-9) said :
#2

Thanks. I will try it and reply later.

Revision history for this message
gaoxuesong (260582472-9) said :
#3

Thanks, it works.