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.

Set of Macros for copying properties from one entity to another.

Started by Lar, February 17, 2011, 01:28:47 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Lar

5 of the macros below are for copying properties from existing entities to other existing entities. The 6th is for changing the fixed lineweight.

I split the set into different macros to avoid having to respond to messages so they ask no questions and report no data, just make changes. You have to know what layer the entity is on beforehand.

I have them in their own toolbox so a max of 3 clicks will get the job done: #1 to select the 'target' entity to change, if it isn't already; #2 in the toolbox for the macro; #3 to select the 'source' entity to get the properties from. The first 'target' selection gets reselected automatically.

I just added a bunch of notes in the first macro for the sake of you forum guys. Please read and make adjustments to all the macros to suit your own needs. These notes will not appear during the running of the macro (as they are now written).


'Copy All Entity Properties.d3m
'by Lar, Nassau, Bahamas
'created around Jan 2006

'INSTRUCTIONS: 1] Select target entity(s), 2] start macro, 3] select source entity...   The Layer, Color, Linestyle and Fixed Lineweight will be copied to the 1st entity(s) ['the target']

'IMPORTANT:
'If regenerating would slow down your system then add an apostrophe (') at the start of the last line of this macro but you may not see the change until the screen refreshes (the entity WILL be changed, though)...
'......If your Info Box is slow then close it before running the macro so it doesn't have to repopulate the new data for the target entity.

'IMPORTANT:
'You can remove the apostrophe from the 'message' line if you want to be prompted...

'If a group or solid is the source then parameters of the 1st entity (in dcad's id list) of that group will be used...

'If the source has 'Color/Linestyle by Layer' activated the target will take these properties but the 'by layer' status of the source will not change (the target will end up looking like how the target looks), except as in the notes below...

'If the target has 'Color/Linestyle by Layer' activated you will not see the change until you deactivate these settings...

'Note that there are a wide range of possibilities that can result depending on the exact 'by Layer' settings of the source, the target, and which properties you are changing...

'IMPORTANT:
'IMPORTANT:
'IMPORTANT: revise the two 'include' lines below to suit the location of your  dcacalias.d3i file...


'Include "*\dcadalias.d3i"
Include "c:\macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

'message "Click on the Entity to Copy All standard properties from..."

>PointSelect
{
}

GetSelect 1, e2nd
Entity e2nd

Query Ent_Layer, elayer
Query Ent_Color, redval, greenval, blueval
Query Ent_Linetype, eltype
Query Ent_LineScale, eltypescale
Query Ent_LineWidth, elwidth
Query Ent_LineFill, elfilled
Query Ent_LineWeight, elweight
Query Ent_FixedWidth, elfixed

sys(80)=0  'deselect everything...

for eee=1 to NumSel
Entity ent(eee)

Change Ent_Layer, elayer
Change Ent_Color, redval, greenval, blueval
Change Ent_Linetype, eltype
Change Ent_LineScale, eltypescale
Change Ent_LineWidth, elwidth
Change Ent_LineFill, elfilled
Change Ent_LineWeight, elweight
Change Ent_FixedWidth, elfixed

Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select

next eee

regen    'regenerate screen




'Copy Entity Color.d3m
'by Lar, Nassau, Bahamas
'created: 22 Jan 2006
'revised 24 May 2007: turn off message telling user to click on entity whose color to copy


'Include "*\dcadalias.d3i"
Include "c:\macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

'message "Click on the Entity to Copy Color from..."

>PointSelect
{
}

GetSelect 1, e2nd
Entity e2nd

Query Ent_Color, redval, greenval, blueval

sys(80)=0  'deselect everything...

for eee=1 to NumSel
Entity ent(eee)

Change Ent_Color, redval, greenval, blueval

Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select


next 'eee

regen    'regenerate screen



'Copy Entity Layer.d3m
'by Lar, Nassau, Bahamas
'created: 22 Jan 2006
'revised 24 May 2007: turn off message telling user to click on entity whose layer to copy

'Include "*\dcadalias.d3i"
Include "c:\macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

'message "Click on the Entity to Copy Layer from..."

>PointSelect
{
}


GetSelect 1, e2nd
Entity e2nd

Query Ent_Layer, elayer

sys(80)=0  'deselect everything...

for eee=1 to NumSel
Entity ent(eee)

Change Ent_Layer, elayer

Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select

next eee

regen    'regenerate screen



'Copy Entity Linestyle.d3m
'by Lar, Nassau, Bahamas
'created: 22 Jan 2006
'revised 24 May 2007: turn off message telling user to click on entity whose linestyle to copy

'Include "*\dcadalias.d3i"
Include "c:\macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

'message "Click on the Entity to Copy Linestyle from..."

>PointSelect
{
}

GetSelect 1, e2nd
Entity e2nd


Query Ent_Linetype, eltype
Query Ent_LineScale, eltypescale
Query Ent_LineWidth, elwidth
Query Ent_LineFill, elfilled
Query Ent_LineWeight, elweight
Query Ent_FixedWidth, elfixed

sys(80)=0  'deselect everything...

for eee=1 to NumSel
Entity ent(eee)

Change Ent_Linetype, eltype
Change Ent_LineScale, eltypescale
Change Ent_LineWidth, elwidth
Change Ent_LineFill, elfilled
Change Ent_LineWeight, elweight
Change Ent_FixedWidth, elfixed

Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select


next eee

regen    'regenerate screen



'Copy Entity Layer & Color.d3m
'by Lar,
'Nassau, Bahamas
'created: 22 Jan 2006
'revised 24 May 2007: turn off message telling user to click on entity whose layer to copy

'Include "*\dcadalias.d3i"
Include "c:\macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

'message "Click on the Entity to Copy Layer from..."

>PointSelect
{
}


GetSelect 1, e2nd
Entity e2nd

Query Ent_Layer, elayer
Query Ent_Color, redval, greenval, blueval

sys(80)=0  'deselect everything...

for eee=1 to NumSel
Entity ent(eee)

Change Ent_Layer, elayer
Update

Change Ent_Color, redval, greenval, blueval
Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select

next eee

regen    'regenerate screen



'Change Fixed Lineweight.d3m
'by Lar,
'Nassau, Bahamas
'created: 22 Jan 2006


'Include "*\dcadalias.d3i"

Include "C:\Macros\dcadalias.d3i"

if sys(80)=0 then
message "Sorry, Entities to Change must be selected already. Select Entities then restart macro..."
end
end if

NumSel=sys(80)   'number of entities selected...

dim ent(NumSel)

for ee=1 to NumSel
getselect ee, ent(ee)
next ee

elweight=40
input "Enter New Fixed Weight (def=40; [some examples: 0,5,9,15,20,30,40,50,60,80, 100, 140, 200] ..." elweight
if sys(999) then end
'sys(80)=0  'deselect everything...

if elweight=0 then elfixed=0
if elweight<>0 then elfixed=1

for eee=1 to NumSel
Entity ent(eee)

Change Ent_LineWeight, elweight
Change Ent_FixedWidth, elfixed
'Change Ent_LineFill, elfilled

Update

'reselect original entities...
GETATTR ent(eee), type ,select
select=1
PUTATTR ent(eee), type ,select

next eee

regen    'regenerate screen



Lar

edgar

-Ed

Dr PR

Lar,

Thanks! Maybe these will help me avoid having to use the Info Box for the most common operations. Hopefully that will avoid some of the delays inherent in the post-V15 Info Box.
DesignCAD user since 1987

bdeck

Quote from: Lar on February 17, 2011, 01:28:47 PM
Please read and make adjustments to all the macros to suit your own needs.

Hey Lar,

These are some very versatile macros.

They make it possible to do either less ( eg just layers ) or more (eg  ENT_USEPAPERCOLOR ) than the basic same as function, and to copy some properties that the basic function ignores.

Lots of possibilities. Thanks.

BD