Hi,
When I replace elements with iLogic the Inventor Browser is not automatically refreshed.
E.g. I have a file A.ipt and I replace it with B.ipt then in the Brwoser will be shown: A.ipt:1, even when B is already inserted.
Is there some refresh, like "Update Browser nodes when done" ?
These both has no influence on it:
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
By the way. To Update the Browser manually, I have to rename the block nodes (From Filename to Filename). So it's only opening up the Renaming Function and then hitting "ok".
If there's no direct function to update the Browser, maybe there's a way to do the manually way by iLogic?
Best Regards
Passi
The standard method is to rename the browser node manually (for instance to AorB:1). Then use that name in your rule:
Component.Replace("AorB:1", "A.ipt", False)
or
Component.Replace("AorB:1", "B.ipt", False)
With this method, the browser always shows the name "AorB:1" for the component. That is the constant name is used to identify the component in the iLogic rule. The disadvantage of this is that you don't see the particular filename in the browser. Instead, the component name is always the same.
In the Assembly look at Assemble Tab > Productivity > Rename Browser Nodes
You can then select either Filename or Part Number and update the entire browser with one click.
Perhaps we can trigger this programatically?
Public Sub RenameBrowserNodes() Dim oDoc As Document Dim oCommandMgr As CommandManager Set oDoc = ThisApplication.ActiveDocument Set oCommandMgr = ThisApplication.CommandManager Call oCommandMgr.ControlDefinitions.Item("AssemblyBonusTools_RenameBrowserNodesCmd").Execute2(True) End Sub
I ended up writing an automated solution in iLogic - quite easy actually.
Exactly what you were doing manually, but automaticly, lol
It fills in the name with a blank, which resets the name with current information.
'J.Kriek 2012 Dim oAssy As AssemblyDocument: oAssy = ThisApplication.ActiveDocument Dim thisOcc As Integer For thisOcc = 1 To oAssy.ComponentDefinition.Occurrences.count oAssy.ComponentDefinition.Occurrences(thisOcc).Name = "" Next thisOcc
Set a trigger for on save and your done 😉
Hi,
I tried your ilogic-code in INV2012proSP2 and Ilogic says that there is following error
"method arguments must be enclosed in parentheses"
Also doesn't help if I check the "VB-only" checkbox in rules-editor.
Can you imagine what's wrong?
Thank you in advance
Hel
Interesting, I have repeated your error, but I have no idea why it's doing that. The code works fine in VBA in all the latest versions and 2011 iLogic, but not in 2012 iLogic. They must have changed something.
Lets try this. Go to Tools > VBA Editor
Then Create a new Module by right-clicking the Project and choosing Insert > Module
Then paste this in that Module:
Public Sub ResetBrowser() 'J.Kriek 2012 Dim oApp As Application Set oApp = ThisApplication If oApp.ActiveDocument.DocumentType = kAssemblyDocumentObject Then Dim oAssy As AssemblyDocument Set oAssy = oApp.ActiveDocument Dim thisOcc As Integer For thisOcc = 1 To oAssy.ComponentDefinition.Occurrences.count oAssy.ComponentDefinition.Occurrences(thisOcc).Name = "" Next thisOcc End If End Sub
Then in the iLogic Rule put the following:
InventorVb.RunMacro("VBAProjectName", "ModuleName", "ResetBrowser")
Be sure to change VBAProjectName and ModuleName to what you named them.
Hello again,
this works - thank you.
Additional question:
I'd like to achive that the browser-name is always set to PARTNUMBER & "-" & "CUSTOMPROPERTY". This is no problem with your code now.
But will this work in normal workflow? How can the browser-names be updated automatically?
Cheers,
Hel
Hi again,
thank you for the information. I tried to add some code in vba to extract a certain iproperty but I always get an error
("Invalid procedure call or argument")
Public Sub ResetBrowser() 'J.Kriek 2012 Dim oApp As Application Set oApp = ThisApplication If oApp.ActiveDocument.DocumentType = kAssemblyDocumentObject Then Dim oAssy As AssemblyDocument Set oAssy = oApp.ActiveDocument Dim thisOcc As Integer Dim DocName, Prop As String Dim oPartDoc As Document For thisOcc = 1 To oAssy.ComponentDefinition.Occurrences.Count oAssy.ComponentDefinition.Occurrences(thisOcc).Name = "" DocName = oAssy.ComponentDefinition.Occurrences(thisOcc).ReferencedDocumentDescriptor.FullDocumentName Set oPartDoc = ThisApplication.Documents.Open(DocName, False) Prop = oPartDoc.PropertySets(CustomSet).Item("Benennung Zeile 1").Value Debug.Print thisOcc; Tab(10); DocName; Tab(10); Prop; Set oPartDoc = Nothing Next thisOcc End If End Sub
the Macro stopps in the line where the iProperty is read. This line I used in an other (working) macro...
Output in the Immediat-window for now.
Do you have an idea why?
Cheers,
Hel
Hi,
it seems you missed "set" ?
Set Prop = oPartDoc.PropertySets(CustomSet).Item("Benennung Zeile 1").Value
In addition, are you sure your custom property in the part document has the internal name "CustomSet"?
Hello Xiaodong,
there is no need for a set command because the Prop variable is only a string not an object.
BUT - thank you for the hint with the CustomSet. Normally I use this naming as a public constant to use this in several VBA-macros.
This macro I put in a document project for testing and this constant was not available.
Cheers