Community
PowerShape Forum
Welcome to Autodesk’s PowerShape Forums. Share your knowledge, ask questions, and explore popular PowerShape topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Apply a macro to more than one ''object''

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
cagnoni.giacomo
627 Views, 4 Replies

Apply a macro to more than one ''object''

 

Hello everyone.

I need your help to '' improve '' a macro.
The macro base is as follows and it works like this:
I manually selected a compcurve and the macro creates a circle in the center of it X Y, and Z minimum.
This macro works by selecting one compcurve.

 

 

********************************************
STRING name = selection.name[0]


REAL X = compcurve[$name].cog.x


REAL Y = compcurve[$name].cog.y


REAL Z = selection.min_range.z


create arc FULL
r 3.5
$X $Y $Z

********************************************

Now I would like to select more than one compcurve and apply the macro to each one of them

How can I do that?

Thank you
Giacomo

4 REPLIES 4
Message 2 of 5

Try this:

 

LET $i = 1
LET $num = selection.number
LIST $select_names = SELECTION.NAMES


LET carry_on = ($i <= $num)
WHILE $carry_on {
	
	SELECT CLEARLIST
	STRING $name = $select_names[$i]
	add CompCurve $name
	REAL $X = compcurve[$name].cog.x
	REAL $Y = compcurve[$name].cog.y
	REAL $Z = selection.min_range.z
	create arc FULL
	r 3.5
	$X $Y $Z

LET $i = $i + 1
LET carry_on = ($i <= $num)
}

Rafael Sansão

EESignature

Message 3 of 5

 

Thank you
Is perfect working properly.

 

A curiosity.


I have tried this way but it doesn't work

 

***************************************
LET numturn = selection.number

WHILE $numturn {

LET numturn = $numturn - 1

STRING name = selection.name[$numturn]

REAL X = compcurve[$name].cog.x
REAL Y = compcurve[$name].cog.y
REAL Z = selection.min_range.z

create arc FULL
r 3.5
$X $Y $Z

}

***************************************

 

What's wrong in my macro?

 

 

Thank you

Message 4 of 5

When you create the first circle, the selection of composite curves is lost. This generates the error in your macro.

 

Try "RESTORE_SELECTION"

 

LET numturn = selection.number

WHILE $numturn {

LET numturn = $numturn - 1

STRING name = selection.name[$numturn]

REAL X = compcurve[$name].cog.x
REAL Y = compcurve[$name].cog.y
REAL Z = selection.min_range.z

create arc FULL
r 3.5
$X $Y $Z
RESTORE_SELECTION
RESTORE_SELECTION
}

Rafael Sansão

EESignature

Message 5 of 5

Very well!

 

 

Now the macro works correctly!

 

 

Thank you

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report