Hi all,
Writing some code for work and having odd issues. Was wondering if someone with more knowledge and experience could point me in the right direction?
We work on many files which all nest and interact together in the same coordinate system.
As we’re all on Mac we don’t have access to .rws so I’ve been writing some code that does the following:
- Asks for user input on what project is being worked on
- Asks for specific area in focus
- Scans through the file system for .3dm files which match these criteria
- Imports all files
- Does some further cleanup using SelBox, Delete and Purge
The problem I am having is that repeatedly all files imported are in the wrong place. The cluster of imports are all located correctly in relation to each other but not to the workspace origin. Importing/Inserting manually drops them in the exact same location; correct with relation to other jobs, but not to the WCS. This happens regardless of whether I’ve restarted Rhino. It should be noted all files are Rhino .3dm, all files are modelled to nest together in the same coordinate system and the workspace I’m inserting them into is completely fresh, empty and has a default ModelBasePoint of 0,0,0. It is crucial that all model’s global positioning is correct relative to the workspace origin.
Here’s the function I’ve been writing:
def ImportRhinoModelsFromList(files):
# Work through the global list of relevant Rhino filepaths and import them into CAD environment
for f in files: # Where "files" is a list of .3dm model filepaths
rs.Command('-Import "' + f + '" Enter')
# NOTES ON IMPORTING
# Through testing the following format was shown to work:
# rs.Command('-Import "[REDACTED]/Project/Model Issue 4 29-06-2022.3dm" Enter')
# By formatting as rs.Command('Import "' + FilePath + '" Return') the string stored in Filepath will enter the command surrounded by quotation marks
Not exactly groundbreaking or with any hidden gremlins as far as I can see!
The only other bit of my code that deals with coordinates at all is further down where I use SelBox and some coordinates read from a file to make some selections These select in the coordinates intended but as the model isn’t in the right place do nothing.
Any advice on what I’m missing or where I should be looking?
Many thanks in advance!
1 post - 1 participant