Macro for Workplane at Pick Position on Block - Possible?

Anonymous

Macro for Workplane at Pick Position on Block - Possible?

Anonymous
Not applicable

Is it possible to use a macro to create a workplane that has its location defined by the standard pick points (orange, yellow, green), and work for different block sizes?  The pickpoints seem to be defined by their absolute location not location relative to the block.

 

The workplane location wouldn't have to be at the pick points, as long as the location was always relative to the outer dimensions of the block.Pick Points ShownPick Points Shown

When viewing the command window during picking points is shows the following line:

 [_PICK_21068_\r] 

does anyone know what the number relates to, it changes for each point but seems a bit random.

Any help with this would be appreciated.

Thank you

0 Likes
Reply
Accepted solutions (1)
2,065 Views
9 Replies
Replies (9)

rafael.sansao
Advisor
Advisor

You can do the calculation and transform the workplane. Here is an example:

REAL $X = $Block.Limits.Xmin + (($Block.Limits.Xmax - $Block.Limits.Xmin) / 2)
REAL $Y = $Block.Limits.Ymin + (($Block.Limits.Ymax - $Block.Limits.Ymin) / 2)
REAL $Z = $Block.Limits.Zmax

CREATE WORKPLANE ; EDITOR
MODE COORDINPUT COORDINATES $X $Y $Z
MODE WORKPLANE_EDIT FINISH ACCEPT
ACTIVATE WORKPLANE #

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

peter.lockyer
Autodesk
Autodesk

Yes, there are commands to pick the coloured blobs whilst you're in the mode:

MODE WORKPLANE_CREATE ; INTERACTIVE BLOCK
MODE WORKPLANE_CREATE BLOCK XMIN YMID ZMAX

Obviously, the command takes an X, Y and Z value, and for each a MIN, MID or MAX modifier.

I hope that helps.



Peter Lockyer

Software Development Manager, Fusion 360 Manufacturing and PowerMill

Anonymous
Not applicable

I think this is definitely going to help, thank you , much appreciated!

 

0 Likes

Anonymous
Not applicable

Hi Raphael, 

 

I have a couple of questions......

When I try to create a second WP with different values i get several errors "local variable already defined: x" y, z, .

any tips for getting past this? seems like i would need to define a new variable but not sure how to label them.

 

Also when I try to rename the WP

EXPLORER SELECT Workplane "Workplane\1" NEW 
RENAME Workplane "1" "TOP MID"

it only works if I paste it into the command line as a separate function, rather then adding it to the other code.

 

This is one of my first experiments with writing macros, so that's probably half the problem!

0 Likes

rafael.sansao
Advisor
Advisor
Accepted solution

You can create the Workplane with the correct name. It is not necessary to rename.

For the second workplane, you can not declare the variables again.
Check out the example:

// First Workplane
REAL $X = $Block.Limits.Xmin + (($Block.Limits.Xmax - $Block.Limits.Xmin) / 2)
REAL $Y = $Block.Limits.Ymin + (($Block.Limits.Ymax - $Block.Limits.Ymin) / 2)
REAL $Z = $Block.Limits.Zmax

CREATE WORKPLANE "TOP MID" EDITOR
MODE COORDINPUT COORDINATES $X $Y $Z
MODE WORKPLANE_EDIT FINISH ACCEPT
ACTIVATE WORKPLANE #

// Second Workplane
$X = $Block.Limits.Xmin + (($Block.Limits.Xmax - $Block.Limits.Xmin) / 2)
$Y = $Block.Limits.Ymin + (($Block.Limits.Ymax - $Block.Limits.Ymin) / 2)
$Z = $Block.Limits.Zmin

CREATE WORKPLANE "BOTTON MID" EDITOR
MODE COORDINPUT COORDINATES $X $Y $Z
MODE WORKPLANE_EDIT FINISH ACCEPT
ACTIVATE WORKPLANE #

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Anonymous
Not applicable

Thanks again for your help Raphael, 

 

I have to remove this line:

ACTIVATE WORKPLANE #

then it to work as anticipated otherwise the  second WP seems to be calculated from the previous WP?

 

0 Likes

rafael.sansao
Advisor
Advisor

That's right.

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes

Anonymous
Not applicable

Raphael, 

 

This is working really well for me, I was able to have the WP change location relative to block size, and also added some code to orientate the WP.  This is a great platform for me to expand upon.  I'm planning to add some additional clearance WP's for transitional movements between toolpaths.

 

Thanks for helping us!

 

I've attached my macro for reference.

 

 

0 Likes

rafael.sansao
Advisor
Advisor

Very good. Congratulations on your work.

If your question has been answered, mark the answer as "accepted solution"

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes