News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Copy layer macro

Started by Pearlitic, May 25, 2016, 09:24:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pearlitic

I have one layer with 29 objects in it.

I want to write a macro that copies layer 1 (all 29 objects) to layer 2, 3, .......up to layer 29.  In other words, I want to copy 1 layer into 29 layers.  I can do this manually, but it's not elegant and not what I want.

Is there a simple macro that will do this?  See attachment.

Thanks,

Pearlitic


Bob P

If they were single entities, a macro would be relatively easy, but those have multiple parts.  Are they each defined as a single solid?

Pearlitic

Yes after a good deal of programing, all 29 objects are solids.  If there isn't an easy way to do this, I will create a work around. 

I just didn't want to get done and find out that all I had to do was to copy layers.

Thanks,


Pearlitic



Bob P

Look in the macro documentation for getattribute and putattribute. It should be easy to cycle through all the entities to find the solids, simultaneously incrementing the layer value when a solid is found.

DrollTroll

If you've got exactly 29 solids, use the PackSolidIDs command to force the solid ids to all be in the range 1 to 29.

In your macro, cycle through each entity, use GetAttr to get its Solid ID, and use PutAttr to change its Layer number to match the Solid ID. Or you could use Query/Change as well, but probably GetAttr/PutAttr is faster and easier.
25 years with DesignCAD

Rob S

Would not Gettattr and Putattr MOVE the solid to the new layer, I think Pearlitic wants to COPY them.

Best way I know to do this is to go to the Layer Options dialog

Select the layer (1) to be copied

Right click, copy layer, and enter the layer number (2) to copy to.

This COPIES all entities on layer 1 to layer 2, which you can't see onscreen unless you relocate one of them, and see the copy underneath.

I don't know offhand if this action could be recorded in a macro, and repeated for the remaining layers, but it is so quick, it might be easier to just do by hand unless this was going to need doing frequently again in the future....
User since forever

DrollTroll

#6
D'oh! You're right -- I didn't read the original post thoroughly enough.

Set Layer 1 current.
Select All.
Duplicate in place
Set Layer 2 current.
ApplyLayer (moves selection to layer 2)
Duplicate in place.
Set Layer 3 current.
ApplyLayer.
etc.

Or, easier:
Selectlayer
{
<Layer 1
<Type 0
}
For i = 2 to 29
>DuplicateToLayer
{
<Layer
}
Next i
End
25 years with DesignCAD

Lar

I think DT left out some stuff:


>Selectlayer
{
<Layer 1
<Type 0
}

For i = 2 to 29

>DuplicateToLayer
{
<Layer [i]
}

Next i

End


DrollTroll

Yep. Stupid editor took my square bracket and 'i' to be the start of italics, apparently. *forehead smack*
25 years with DesignCAD

Lar

Yea, it did that to me too at first so I had to put it in the 'code'.

...Also the > at the start.

Lar

Pearlitic

Thanks everyone.  I have a few ideas to try out.  Sorry, I've been offline for a day or two, but it's back to the salt mine.

I'll get back to you all after I play with this a bit more.

Thank you.

Gary