Is is possible to “import” a file into a target file so that the layers and objects in the imported file are sublayers under a selected layer in the target file? So far all efforts result in the imported objects being in previously existing layers in the target file, not in separate layers. I have tried Import, Insert, and creating a worksession with files to be imported as attached files and then using Copy with the Inplace option.
I have four files, each with the same layer names and structure. Let’s name them BoatA, BoatB, BoatC and BoatD.
I create a new file named AllBoats, and in the file I create layers A, B, C and D.
I want to import the layers and objects in source file BoatA into AllBoats and have them under layer A in AllBoats. Next I want to import the layers and objects in source file BoatB into AllBoats and have them under layerB in AllBoats. And so forth.
The first time I run the script the file to be imported is put in the current layer of the open file.
The second time I run the script the layer in the open file which now has sublayers with the same names as the layers in the file to be imported is put in the now current layer of the open file, and the objects in the file to be imported are put into the existing layers with the same names.
@davidcockey that is what is expected - as I mentioned, I can make it ask you for a layer. Does it work to the extent that you set the right layer current before running it?
I see, OK - so you have the top level layer in the incoming file and in the parent file as well… so I need to ditch the top level layer in one or the other. Bringing in a file without that top level layer seems OK.
@pascal Incorrect. The “top level layer” is not in the file being imported. The name of the “top level layer” may or may not be the same as as name of the file being imported into that layer. In the example files I provided one source file is Rowboat11 and it needs to be imported under Rowboat.
@Pascal My mistake. I meant to eliminate the top layers in the example source files. Below are revised source files. Canoe.23dm.3dm (2.9 MB) Rowboat112.3dm (2.8 MB) Kayak2.3dm (2.9 MB)
In an ideal world I’d like to not have problems if a top level layer of the file being imported matches a top level layer in the target file.
Yeah, it can be done, I just need to scratch those few remaining brain cells. @davidcockey - I had another go at it - updated above - is that any better?
drawing some curves on a frist document
copy paste
rename parent layer doc1 → doc2
move objects
copy back
… result is as expected here - layer structure kept
i am missing something ?
did not find any preferences that might influence this behavior
I need to copy layer structure and objects from one file to another. When I do that the objects go into the current layer.
If I want to create a new set of layers with copies of objects in a single file I use “Duplicate layer and objects” and select the appropriate options.
Selected Canoe as current layer.
RunPythonScript and selected Canoe2.3dm as file to import.
As desired, objects and layers from Canoe2.3dm appear under layer Canoe in All In One.3dm. This is as desired.
Select Rowboat as current layer.
RunPythonScript and selected Rowboat112.3dm as file to import.
Objects from Rowboat112.3dm appear in corresponding layers under layer Canoe in All In One.3dm
Desire was for the imported objects and layer structure from Rowboat112.3dm to appear under current layer of Rowboat in All In One.3dm
Select Kayak as current layer.
RunPythonScript and selected Kayak2.3dm as file to import.
Objects from Kayak2.3dm appear in corresponding layers under layer Canoe in All In One.3dm
Desire was for the imported objects and layer structure from Kayak2.3dm to appear under current layer of Kayak in All In One.3dm
Results from above (corrected):Wrong files uploaded
Windows 10.0.19043 SR0.0 or greater (Physical RAM: 64Gb)
Computer platform: DESKTOP
Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce RTX 2080 Ti (NVidia) Memory: 11GB, Driver date: 8-5-2021 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 471.68
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0
OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)
Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High
Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 8-5-2021
Driver Version: 30.0.14.7168
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 11 GB
Rhino plugins that do not ship with Rhino
C:\Program Files\Orca3D V2\Orca3D.rhp “Orca3D” 2.0.22.0