cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a part in assembly tree "active", via VB.Net or MapKey

Highlighted
Level 1

How to make a part in assembly tree "active", via VB.Net or MapKey

I need a tool to automatically activate a specific part in an assembly tree structure.

Manually i would search the tree for the part, Right Mouse Button ---> Activate

I have experimented using macro recording for generating a mapkey, but this is a static dumb solution, that i cannot "parametrize" with the model name i have to activate.

So, i'm asking to all gurus there, if the "inplace part activation" can be automated in any way.

On VB.Net --> session.GetActiveModel() --> return the active part, BUT i have not found any SetActiveModel() to do the job, why ???

I don't handle very well Script/mapkey syntax, can i parametrize the recorded script with my own model name to activate ?

Looking for a tricky solution, regards,

Tags (1)
4 REPLIES 4

Re: How to make a part in assembly tree "active", via VB.Net or MapKey

mapkey act ~ RButtonArm `main_dlg_cur` `PHTLeft.AssyTree` `node69`;\

mapkey(continued) ~ PopupOver `main_dlg_cur` `ActionMenu`1 `PHTLeft.AssyTree`;\

mapkey(continued) ~ Open `main_dlg_cur` `ActionMenu`;~ Close `main_dlg_cur` `ActionMenu`;\

mapkey(continued) ~ Activate `main_dlg_cur` `MakeActive`;

This seems to work in WF5. Pick an item on the tree and use the mapkey to activate it.

I recorded it by first selecting an item, then starting the mapkey recorder, right clicked next to some datum planes to get Activate without activating a different part, and then stopped the recording.

Re: How to make a part in assembly tree "active", via VB.Net or MapKey

Hi,

When you select on the tree, Creo only records the sequential number of that component in the tree (starts with "node0", "node1", "node2"...)

So you can´t use it the way you want.

A more powerful way of selecting components is using the FIND tool (the binoculars at bottom right in Creo 2).

You can use a lot of filters to select components.

I suggest:

Find-> Look for:Component -> Rule:Name -> Criteria:is equal to:yourpartname.prt

Then RMB and activate.

Now, you have to keep in mind one thing: how many times is that component repeated in the assembly? If more than one this will not work because you will have various possible results.

In this situation you use the Find tool search by the feature ID. This will give only one possible result. The disadvantage is that you will not be able to use it on another assembly.

Hope this helps.

Jose

Re: How to make a part in assembly tree "active", via VB.Net or MapKey

Try this mapkey to select by name:

mapkey activate ~ Command `ProCmdMdlTreeSearch` ;\

mapkey(continued) ~ Select `selspecdlg0` `SelOptionRadio` 1 `Component`;\

mapkey(continued) ~ Select `selspecdlg0` `ExtRulesLayout.ExtBasicNameLayout.BasNameComp` 1 ` \

mapkey(continued) == `;~ Open `selspecdlg0` `ExtRulesLayout.ExtBasicNameLayout.BasicNameList`;\

mapkey(continued) ~ Close `selspecdlg0` `ExtRulesLayout.ExtBasicNameLayout.BasicNameList`;\

mapkey(continued) ~ Select `selspecdlg0` `ExtRulesLayout.ExtBasicNameLayout.BasicNameList` 1 \

mapkey(continued) `YOURPARTNAME.PRT`;~ Activate `selspecdlg0` `EvaluateBtn`;\

mapkey(continued) ~ Activate `selspecdlg0` `ApplyBtn`;~ Activate `selspecdlg0` `CancelButton`;\

mapkey(continued) ~ RButtonArm `main_dlg_cur` `PHTLeft.AssyTree` `node`;\

mapkey(continued) ~ PopupOver `main_dlg_cur` `ActionMenu` 1 `PHTLeft.AssyTree`;\

mapkey(continued) ~ Open `main_dlg_cur` `ActionMenu`;~ Close `main_dlg_cur` `ActionMenu`;\

mapkey(continued) ~ Activate `main_dlg_cur` `MakeActive`;

Just replace YOURPARTNAME.PRT with your part name and the name of the mapkey if you wish.

Re: How to make a part in assembly tree "active", via VB.Net or MapKey

Wow.. i didn't expect Ptc macro Scripts to be so powerful.

I'm anyway still puzzled if a "native" pro/Toolkit-Jlink-vbapi really exist for activating a component from code, but this mapkey would be a nice workaround at the moment. Do you know of any documentation on mapkey commands syntax ?

I would investigate split the problem in two part, select the proper part element from code (if any API exist for highliting component directly on tree) and execute only the latest mapkey command "Activate 'main_dlg_cur' 'MakeActive' to perform the final action, so i should have on paper much more control on the proper item to activate.

I need the explicit activation because of a nasty bug in vbapi .CreateUdfGroup()

For some arcane reasons, it refuse to create the feature group on the part it that part is not activated WHEN the CSYS reference for UDF placement is external to the part itself. If you don't make it active, the feature fails or will be created at wrong place, most probably due to internal matrix transformations that take into consideration wich part is active.

Maybe if i had some code example on creating UDF with external references that works, i dont need to activate the part anymore. The example code provided on vbapi documentation are not suitable because it creates feature group at assembly level, i need to create UDF holes in a part nested on tree.

Anyone has a working example of UDF placement (using ext-reference) that really works ?