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: 

Name in browser ?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
joel.bonnet
678 Views, 5 Replies

Name in browser ?

hello all,

 

I'm search a name in browser, but were is it ?

 

is not that !!

For Each oDoc In ThisApplication.Documents

     nom_arbore = oDoc.DisplayName

 

thank's and sorry for my bad english.

5 REPLIES 5
Message 2 of 6

Hi,

I don't know if this is exactly what you need but I'ld try... the variable named "oOcc.Name" contain the name of each occurence.

 

Lista = ""
For Each oOcc In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.AllLeafOccurrences
	Lista &= oOcc.Name & vbCr
Next
	MsgBox(Lista)

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 3 of 6

thank's a lot but i'm not have sub-assembly in  this list ...

 

i'm shearch...

Message 4 of 6

Hi, if you look inside the API help of your Inventor you will find this example.

 

Public Sub AssemblyCount()
    ' Set reference to active document.
    ' This assumes the active document is an assembly
    Dim oDoc As Inventor.AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    ' Get assembly component definition
    Dim oCompDef As Inventor.ComponentDefinition
    Set oCompDef = oDoc.ComponentDefinition

    Dim sMsg As String
    Dim iLeafNodes As Long
    Dim iSubAssemblies As Long
    
    ' Get all occurrences from component definition for Assembly document
    Dim oCompOcc As ComponentOccurrence
    For Each oCompOcc In oCompDef.Occurrences
        ' Check if it's child occurrence (leaf node)
        If oCompOcc.SubOccurrences.Count = 0 Then
            Debug.Print oCompOcc.Name
            iLeafNodes = iLeafNodes + 1
        Else
            Debug.Print oCompOcc.Name
            iSubAssemblies = iSubAssemblies + 1
            Call processAllSubOcc(oCompOcc, _
                                sMsg, _
                                iLeafNodes, _
                                iSubAssemblies) ' subassembly
        End If
    Next
    
    Debug.Print "No of leaf nodes    : " + CStr(iLeafNodes)
    Debug.Print "No of sub assemblies: " + CStr(iSubAssemblies)
End Sub

' This function is called for processing sub assembly.  It is called recursively
' to iterate through the entire assembly tree.
Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence, _
                             ByRef sMsg As String, _
                             ByRef iLeafNodes As Long, _
                             ByRef iSubAssemblies As Long)
    
    Dim oSubCompOcc As ComponentOccurrence
    For Each oSubCompOcc In oCompOcc.SubOccurrences
        ' Check if it's child occurrence (leaf node)
        If oSubCompOcc.SubOccurrences.Count = 0 Then
            Debug.Print oSubCompOcc.Name
            iLeafNodes = iLeafNodes + 1
        Else
            sMsg = sMsg + oSubCompOcc.Name + vbCr
            iSubAssemblies = iSubAssemblies + 1

            Call processAllSubOcc(oSubCompOcc, _
                                  sMsg, _
                                  iLeafNodes, _
                                  iSubAssemblies)
        End If
    Next
End Sub

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 5 of 6

Thanks a lot it's perfect !

 

But i'm dont find help in my inventor, i have juste basicly help for vba.

 

Do you have an idea for install this or where are you find this ?

 

thank's a lot

Message 6 of 6

Look at this link.
http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112

Bregs
Rossano Praderi


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------

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

Post to forums  

Autodesk Design & Make Report