Community Tip - You can change your system assigned username to something more personal in your community settings. X
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
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()
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
You can set the property after creation
regen.RefreshModelTree = True
Hi,
Ok so I tried a few things and I think I understood how to make the RegenInstructions work.
First of all I was getting a compile error when trying to use the created regen instructions into thre Regenerate method :
'IpfcSolid.REGENERATE TEST
Dim regen_instr As New CCpfcRegenInstructions
Dim regen As IpfcRegenInstructions
Dim solid As IpfcSolid
Set regen = regen_instr.Create(False, True, Null)
regen.RefreshModelTree = True
Set solid = model '(model is defined as a pfcls.IpfcModel session.currentModel)
solid.Regenerate (regen)
This was getting me a "method or data member not found" error on the last line with the solid.Regnerate (regen) method.
Probably due to the no typecast in VBA, I found that if a create a second IpfcRegnInstructions without declaring it (no Dim) and only setting it as equal to the first one correctly defined the program runs and actually runs the regeneration process (see screen attached)
Unfortunately this does not solve the layer tree not updating, even with the RefreshModelTree property.
I think I'm at a bit on an impasse for now.