Notifications
Clear all

[Closed] plans extraction maxscript

I am writing a script that would allow me to extract architectural plans from 3ds max scenes organized with standard layers conventional names (e.g. A-WALL, A-GLAZ etc…).
Since I do not seem to be able to set the active layer directly, I am doing it via selection of objects by name and then use LayerSet to set the selected object’s layer as the active layer. This has the inconvenient of involving an object naming convention in addition to the layer one.

How can I set the active layer via maxscript as done using the Layers Toolbar Dropdownlist?
I am attaching a file that I am using to test the code.

Also, I am sure I am doing all sort of other mistakes and I would certainly appreciate any feedback on the entire code.

Thanks in advance, Best.

– here a statement is needed to set the active layer A-WALL, A-GLAZ etc…, in the example below I am setting the layer via object selection, select by property “layer” would be preferrable
select $WALL01 –
macros.run “Layers” “LayerSet” – set selected object’s layer as the active layer
macros.run “Layers” “LayerSelect” – select all objects on current layer
macros.run “Tools” “Isolate_Selection”
s = section length:1000 width:1000 pos:[0,0,48] isSelected:on
convertToSplineShape s – create section spline
Iso2Roll.C2Iso.changed true – exit isolation tool
clearSelection()
select $FixedWindow001
macros.run “Layers” “LayerSet”
macros.run “Layers” “LayerSelect”
macros.run “Tools” “Isolate_Selection”
s = section length:1000 width:1000 pos:[0,0,48] isSelected:on
convertToSplineShape s – create section spline
Iso2Roll.C2Iso.changed true – exit isolation tool
clearSelection()
select $PivotDoor001
macros.run “Layers” “LayerSet”
macros.run “Layers” “LayerSelect”
macros.run “Tools” “Isolate_Selection”
s = section length:1000 width:1000 pos:[0,0,48] isSelected:on
convertToSplineShape s
Iso2Roll.C2Iso.changed true
clearSelection()
select $section* – select all sections
exportFile (“C:\ emp\plan.dwg”) #noPrompt selectedOnly:True – export selected objects to dwg file

2 Replies
1 Reply
(@pixel_monkey)
Joined: 11 months ago

Posts: 0

From the Layer Properties MaxScript Help:

<LayerProperties>.current : boolean : Read|Write

EDIT: So in your case you need to get the layer through the LayerManager interface and then set it to current through the LayerProperties. Example:

setLayer = LayerManager.getLayerFromName "A-WALL"
  setLayer.current = true

EDIT – 2: To select the objects by layer you can skip the setting of the current layer and instead use something like:

selectLayer = LayerManager.getLayerFromName "A-WALL"
selectLayer.nodes &selArr
select selArr

-Eric

Thank you very much. That worked fine. I am using the set selected object’s layer so that the spline created will be on the proper layer.
Thank you again!