Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The Browser is not refreshing after replacing elements with iLogic

14 REPLIES 14
Reply
Message 1 of 15
Passi
1094 Views, 14 Replies

The Browser is not refreshing after replacing elements with iLogic

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 

14 REPLIES 14
Message 2 of 15
MjDeck
in reply to: 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.


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 15
Passi
in reply to: Passi

Hi and thanks for the answer.

 

It's not as easy as I hoped it would be 🙂 But ok.

 

Best Regards

 

Passi 

Message 4 of 15
jdkriek
in reply to: Passi

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

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 15
jdkriek
in reply to: Passi

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 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 15
Passi
in reply to: Passi

Nice idea 🙂

 

To get an automatically refresh by changing the name into "" is quiet interesting.

 

Best Regards

 

Passi

Message 7 of 15
h.schkorwaga
in reply to: jdkriek

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

Message 8 of 15
jdkriek
in reply to: h.schkorwaga

lagsgh,

 

I don't get that error in 2012, or 2011-2013 for that matter.

 

Can you post the Assy that you are seeing this error in and any additional code you may be running?

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 9 of 15
h.schkorwaga
in reply to: Passi

incoming!

 

Thanks in advance.

Message 10 of 15
jdkriek
in reply to: h.schkorwaga

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.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 11 of 15
h.schkorwaga
in reply to: jdkriek

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

Message 12 of 15
jdkriek
in reply to: h.schkorwaga

Yes, that should work. Just set an Event Trigger on the iLogic Rule that runs the VBA.

 

I usually set it to "Before Save Document", so the browser will be updated every time the Assembly is saved.

 

trigger.PNG

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 13 of 15
h.schkorwaga
in reply to: jdkriek

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

Message 14 of 15

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"?
 

Message 15 of 15

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report