Importing STL as Solid body
-
Hello,
Simple question but hard to find the solution. When importing an STL file via model.Import(filepath), it imports as a triangle mesh. However, when I do this import manually I get an options box that pops up asking if I want to import as a solid body. Is there some option or flag I can use during the import python line that looks something like Import(filename, asSolid=True)? The reason why I want to do this is because the surface current viewer in the analysis tab only works for solid bodies, not these mesh grid objects.
Thanks for the help!
-
I am not sure this possible atm. Normally, you can find the options by creating an importer object and calling DumpTree on the Options, to see the names of the options.
It seems though, the Solidy option is inside a group with spaces in the name ("Stereo Lithography STL"). The name of the property cannot have spaces, so it is not accessible, e.g. by writing
importer = xcm.CreateImporterFromFile(file_name) importer.Options.Stereo Lithography STL.Solidify.Value = Tre
I guess you could traverse the property group to find the child called "Solidify" and set it's value to
True
. We will investigate and make this option accessible for the 9.0 release.Regarding the actual problem, though. Can you please explain in more detail what you mean by "surface current viewer"? Maybe we can fix this issue for the upcoming 9.0 release - it seems like it may be too restrictive and would be easy to fix.
-
the "Import As Solid" issue is fixed in the dev version. In 9.0, you can do this
importer = XCoreModeling.CreateImporterFromFile(file_name) importer.Options.Solidify.Value = True entities = importer.Import(file_name)
meanwhile, you could use this workaround
def find_property(prop, name): if prop.Name == name: return prop for i in range(prop.Size): child = prop.Children[i] result = find_property(child, name) if result is not None: return result return None solidify = find_property(importer.Options, "Solidify") assert solidify is not None solidify.Value = True entities = importer.Import(file_name) assert len(entities) == 1 and isinstance(entities[0], xcm.Body)