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: 

Accessing properties from component occurence using VB

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
256 Views, 2 Replies

Accessing properties from component occurence using VB

I'm building an VB application which uses Apprentice.
It will rucursively run through an assy and collect property-info of all
its components (and their components etc.)

I decided to basy my code on the AssemblyTree sample supplied with
Inventor.

But I cannot quite understand how I can get access to the component
occurences.
See code:


' Call the recursive function to iterate through the assembly tree:
Call GetComponents(oDoc.ComponentDefinition.Occurrences, TopNode)




'Sub that Gets the components from the Occurrences collection and add it to
the tree.
Private Sub GetComponents(InCollection As ComponentOccurrences, ParentNode
As Node)
Dim PartNumber As String
Dim WebLink As String

' Iterate through the components in the current collection.
Dim oCompOccurrence As ComponentOccurrence
For Each oCompOccurrence In InCollection
'Here, I want to access the Part Number property and WebLink Property
of the
'current component occurence.
'WebLink=?????????
'PartNumber=??????????

' Determine if the current component is an assembly or part.
Dim ImageType As String
If oCompOccurrence.Definition.Document.DocumentType =
kAssemblyDocumentObject Then
ImageType = "Assembly"
Else
ImageType = "Part"
End If
' Display the current component in the tree.
Dim CurrentNode As Node
Set CurrentNode = treList.Nodes.Add(ParentNode, tvwChild, ,
oCompOccurrence.Name, ImageType)
' Recursively call this function for the suboccurrences of the current
component.
Call GetComponents(oCompOccurrence.SubOccurrences, CurrentNode)
Next
End Sub

--
Jorgen Bjornes
----------------------------------------------
Visit the Scandinavian Discussion-forum
For Inventor at www.bjornes.org
----------------------------------------------
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Hmm. Nobody replied.

This could mean 3 things:

1) That I wrote my question so clumsily that no-one understood it.

2) That what I'm trying to do is impossible with Apprentice.

3) That you guys have not bumped into this problem before and do not know
what the solution is.


So which one is it, Or does anyone know 😉 I'd be really glad for any
hint.
I can access the properties of the top assy, but not the nodes....


Jorgen





On Mon, 28 Jul 2003 08:17:07 -0700, Jorgen Bjornes wrote:

> I'm building an VB application which uses Apprentice.
> It will rucursively run through an assy and collect property-info of all
> its components (and their components etc.)
>
> I decided to basy my code on the AssemblyTree sample supplied with
> Inventor.
>
> But I cannot quite understand how I can get access to the component
> occurences.
> See code:
>
>
> ' Call the recursive function to iterate through the assembly tree:
> Call GetComponents(oDoc.ComponentDefinition.Occurrences, TopNode)
>
>
>
>
> 'Sub that Gets the components from the Occurrences collection and add it
> to the tree.
> Private Sub GetComponents(InCollection As ComponentOccurrences,
> ParentNode As Node)
> Dim PartNumber As String
> Dim WebLink As String
>
> ' Iterate through the components in the current collection.
> Dim oCompOccurrence As ComponentOccurrence
> For Each oCompOccurrence In InCollection
> 'Here, I want to access the Part Number property and WebLink Property of
> the
> 'current component occurence.
> 'WebLink=?????????
> 'PartNumber=??????????
>
> ' Determine if the current component is an assembly or part.
> Dim ImageType As String
> If oCompOccurrence.Definition.Document.DocumentType =
> kAssemblyDocumentObject Then
> ImageType = "Assembly"
> Else
> ImageType = "Part"
> End If
> ' Display the current component in the tree.
> Dim CurrentNode As Node
> Set CurrentNode = treList.Nodes.Add(ParentNode, tvwChild, ,
> oCompOccurrence.Name, ImageType)
> ' Recursively call this function for the suboccurrences of the current
> component.
> Call GetComponents(oCompOccurrence.SubOccurrences, CurrentNode)
> Next
> End Sub
>



--
Jorgen Bjornes
----------------------------------------------
Visit the Scandinavian Discussion-forum
For Inventor at www.bjornes.org
----------------------------------------------
Message 3 of 3
Anonymous
in reply to: Anonymous

OK, Found it out myself!!

Here is the code I was looking for:

PartNumber=oCompOccurrence.Definition.Document.PropertySets.Item("{32853F0F-
3444-11d1-9E93-0060B03C1CA6}")
.ItemByPropId(kDescriptionDesignTrackingProperties).Value


I found the clue for this (.Definition.Document.PropertySets.) in "Browser
Rename sample & source" at cbliss.com. Thanks Charles!!!
It was really nice to find this project, WITH Sourcecode. Way to go!!


Jorgen



On Thu, 31 Jul 2003 23:39:51 -0700, Jorgen Bjornes wrote:

> Hmm. Nobody replied.
>
> This could mean 3 things:
>
> 1) That I wrote my question so clumsily that no-one understood it.
>
> 2) That what I'm trying to do is impossible with Apprentice.
>
> 3) That you guys have not bumped into this problem before and do not know
> what the solution is.
>
>
> So which one is it, Or does anyone know 😉 I'd be really glad for any
> hint.
> I can access the properties of the top assy, but not the nodes....
>
>
> Jorgen
>
>
>
>
>
> On Mon, 28 Jul 2003 08:17:07 -0700, Jorgen Bjornes
> wrote:
>
>> I'm building an VB application which uses Apprentice.
>> It will rucursively run through an assy and collect property-info of all
>> its components (and their components etc.)
>>
>> I decided to basy my code on the AssemblyTree sample supplied with
>> Inventor.
>>
>> But I cannot quite understand how I can get access to the component
>> occurences.
>> See code:
>>
>>
>> ' Call the recursive function to iterate through the assembly tree:
>> Call GetComponents(oDoc.ComponentDefinition.Occurrences, TopNode)
>>
>>
>>
>>
>> 'Sub that Gets the components from the Occurrences collection and add it
>> to the tree.
>> Private Sub GetComponents(InCollection As ComponentOccurrences,
>> ParentNode As Node)
>> Dim PartNumber As String
>> Dim WebLink As String
>>
>> ' Iterate through the components in the current collection.
>> Dim oCompOccurrence As ComponentOccurrence
>> For Each oCompOccurrence In InCollection
>> 'Here, I want to access the Part Number property and WebLink Property of
>> the
>> 'current component occurence.
>> 'WebLink=?????????
>> 'PartNumber=??????????
>>
>> ' Determine if the current component is an assembly or part.
>> Dim ImageType As String
>> If oCompOccurrence.Definition.Document.DocumentType =
>> kAssemblyDocumentObject Then
>> ImageType = "Assembly"
>> Else
>> ImageType = "Part"
>> End If
>> ' Display the current component in the tree.
>> Dim CurrentNode As Node
>> Set CurrentNode = treList.Nodes.Add(ParentNode, tvwChild, ,
>> oCompOccurrence.Name, ImageType)
>> ' Recursively call this function for the suboccurrences of the current
>> component.
>> Call GetComponents(oCompOccurrence.SubOccurrences, CurrentNode)
>> Next
>> End Sub
>>
>
>
>



--
Jorgen Bjornes
----------------------------------------------
Visit the Scandinavian Discussion-forum
For Inventor at www.bjornes.org
----------------------------------------------

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

Post to forums  

Autodesk Design & Make Report