Help with this macro

Help with this macro

abner_asafe
Contributor Contributor
1,114 Views
10 Replies
Message 1 of 11

Help with this macro

abner_asafe
Contributor
Contributor

Hello, I need help with this macro, at the beginning I need it to show a list with the workplanes to select just one (commented part of the code) after that open the option to create a plane aligned in the geometry and then get the plane that I selected at the beginning and align its top view with the plane aligned in the geometry

 

//   STRING LIST $PlanoP = {}
//   $PlanoP = INPUT ENTITY MULTIPLE Workplane "Selecione o plano de trabalho principal" 
//   GRAPHICS LOCK
//   DIALOGS MESSAGE OFF
//  DIALOGS ERROR OFF
   

 ACTIVATE Workplane INCLINADO


MODE WORKPLANE_CREATE ; INTERACTIVE GEOMETRY
   Macro Pause "Clique na face que deseja alinhar a vista" 


ACTIVATE Workplane "1"
ROTATE TRANSFORM TOP


COPY WORKPLANE INCLINADO
RENAME Workplane "INCLINADO_1" "INCLINADO_X"
MODE WORKPLANE_EDIT START "INCLINADO_X"
MODE WORKPLANE_EDIT ALIGN VIEW
MODE WORKPLANE_EDIT FINISH ACCEPT

delete workplane"1"

 

0 Likes
Accepted solutions (1)
1,115 Views
10 Replies
Replies (10)
Message 2 of 11

icse
Collaborator
Collaborator

you need a entity list insted of a string list:

 

entity LIST $PlanoP = {}
$PlanoP = INPUT ENTITY MULTIPLE Workplane "Selecione o plano de trabalho principal"

 

and for a single workplane use this:

entity $PlanoP = INPUT ENTITY Workplane "Selecione o plano de trabalho principal"

 

0 Likes
Message 3 of 11

abner_asafe
Contributor
Contributor

 

 

 

   entity LIST $PlanoP = {}
	entity $PlanoP = INPUT ENTITY Workplane "Selecione o plano de trabalho principal"
   GRAPHICS LOCK
   DIALOGS MESSAGE OFF
  DIALOGS ERROR OFF
 

 string $planoN= $PlanoP

 ACTIVATE Workplane $PlanoP


MODE WORKPLANE_CREATE ; INTERACTIVE GEOMETRY
   Macro Pause "Clique na face que deseja alinhar a vista" 


ACTIVATE Workplane "1"
ROTATE TRANSFORM TOP


COPY WORKPLANE $PlanoP
RENAME Workplane "$PlanoN" "INCLINADO_X"
MODE WORKPLANE_EDIT START "INCLINADO_X"
MODE WORKPLANE_EDIT ALIGN VIEW
MODE WORKPLANE_EDIT FINISH ACCEPT

delete workplane"1"

 

 

 

 

 


is this corret?

0 Likes
Message 4 of 11

icse
Collaborator
Collaborator

So you whant to change the rotation of the selected workplane with the rotation of the workplane the user created?

0 Likes
Message 5 of 11

abner_asafe
Contributor
Contributor

Yes exactly that

0 Likes
Message 6 of 11

icse
Collaborator
Collaborator

Try this:

entity $PlanoP = INPUT ENTITY Workplane "Selecione o plano de trabalho principal"

string $temp = new_entity_name('workplane','')
MODE WORKPLANE_CREATE ${temp} INTERACTIVE GEOMETRY


Macro Pause "Clique na face que deseja alinhar a vista" 

ACTIVATE Workplane ${temp}

entity $t = entity('workplane',$temp)


bool $sucsess = set_workplane($PlanoP, entity('workplane',$temp).YAxis,entity('workplane',$temp).ZAxis, $PlanoP.Origin ) 


ACTIVATE Workplane ${PlanoP.Name}

purge workplane ${temp} yes
Message 7 of 11

abner_asafe
Contributor
Contributor

works almost perfect i just need to create a copy of the initial selected workplane and aling this copy

 

0 Likes
Message 8 of 11

icse
Collaborator
Collaborator

im not able to test this atm but try this:

 

entity $PlanoP = INPUT ENTITY Workplane "Selecione o plano de trabalho principal"


string $PlanoN = 'INCLINADO_X'

if entity_exists('workplane',$PlanoN) {
	$PlanoN = new_entity_name('workplane',$PlanoN)
}

create workplane $PlanoN

string $temp = new_entity_name('workplane','')
MODE WORKPLANE_CREATE ${temp} INTERACTIVE GEOMETRY


Macro Pause "Clique na face que deseja alinhar a vista" 

ACTIVATE Workplane ${temp}

entity $t = entity('workplane',$temp)


bool $sucsess = set_workplane($PlanoN, entity('workplane',$temp).YAxis,entity('workplane',$temp).ZAxis, $PlanoN.Origin ) 


ACTIVATE Workplane ${PlanoN.Name}

purge workplane ${temp} yes

 

0 Likes
Message 9 of 11

abner_asafe
Contributor
Contributor

it's giving an error in the "bool $sucess" function line

0 Likes
Message 10 of 11

icse
Collaborator
Collaborator
Accepted solution
entity $PlanoP = INPUT ENTITY Workplane "Selecione o plano de trabalho principal"


string $PlanoN = 'INCLINADO_X'

if entity_exists('workplane',$PlanoN) {
	$PlanoN = new_entity_name('workplane',$PlanoN)
}

create workplane $PlanoN

bool $s = 0
$s = set_workplane(entity('workplane',$PlanoN),$PlanoP)

string $temp = new_entity_name('workplane','')
MODE WORKPLANE_CREATE ${temp} INTERACTIVE GEOMETRY


Macro Pause "Clique na face que deseja alinhar a vista" 

ACTIVATE Workplane ${temp}

entity $t = entity('workplane',$temp)


$s = set_workplane(entity('workplane',$PlanoN), entity('workplane',$temp).YAxis,entity('workplane',$temp).ZAxis, entity('workplane',$PlanoN).Origin ) 


ACTIVATE Workplane ${PlanoN}

purge workplane ${temp} yes
Message 11 of 11

abner_asafe
Contributor
Contributor

Perfect thank you

0 Likes