Skip to main content
12-Amethyst
September 6, 2023
Question

VBA api layer tree update

  • September 6, 2023
  • 1 reply
  • 4054 views

Hello, I am working on a few automation projects on Creo 4.0 using the VBA API toolkit.

I have set a macro that searches for empty layers in my model and deletes them : this works as intended but after running the macro, the deleted layers still show in the layer tree.

They can't be interacted with so they are indeed taken as deleted, but hitting regenerate, or repaint does not erase them from the tree, for the regenerate it is because for creo there is nothing to regenerate (I get the message 'part' not changed since last regen)

However, if I do any change in the model (add a sketch or an extrude), the layer tree refreshes and removes the deleted layers.
I am looking for any idea to get the layer tree to refresh because even though the intended function works just fine and I can just keep going and it'll update after a change, I don't find it "tidy" to have these ghost layers lying around ^^

 

I thought about creating a dummy sketch to force the regen and then delete it, but I wonder if it won't just cause the same issue with the model tree not updating the display afterwards, I just hope to see if anyone has a better idea before trying that (not even sure it's possible from the vba api).


The attached images show that on right click on an existing empty layer, I get all the options available on a layer, and after running my program, the right click on the "ghost" thinks I didn't click on a layer (which is technically true)

I'll appreciate any input on this issue
Laetitia.M

 

 

 

1 reply

17-Peridot
September 7, 2023

Hello. Interesting question.

In C ProToolkit we have a function for this ProTreetoolRefresh(). For VB I'm don't know any analog.

So, try to do this:

1. Get current window IpfcBaseSession.CurrentWindow()

2. Activate it IpfcWindow.Activate()

12-Amethyst
September 7, 2023

Hi thanks for the input,

I tried the IpfcWindow.Activate, .Refresh and .repaint and neither of those work.

Here's my code exerpt :

 

Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession

Dim window As IpfcWindow

 

Set conn = asynconn.Connect("", "", ".", 5) 
Set session = conn.session

Set window = session.CurrentWindow()

window.Activate   'changed to .Refresh then .Repaint but the ghost layer remains.

I have also tried regenerating the IpfcSolid with :
IpfcSolid.Regenerate (Null)    'used the Null to pass default regen instructions.

I found the RefreshModelTree property for regen instructions object, but I can't seem to find how to exploit it as the RegenInstruction.Create only asks for 3arguments (noted as optional in guide but mandatory in my VBA).
Thanks again for any input on this issue

17-Peridot
September 8, 2023

You can set the property after creation

regen.RefreshModelTree = True