Select part / Occurence by name

Select part / Occurence by name

Anonymous
Not applicable
455 Views
6 Replies
Message 1 of 7

Select part / Occurence by name

Anonymous
Not applicable
Hi,

Is there an easiest way to select an occurence by it's name :

Sub EraseOccurence(OccurenceName As String)
Dim Occurence As ComponentOccurrence

For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
If Occurence.Name = OccurenceName Then
Occurence.Visible = False
Exit For
End If
Next Occurence
End Sub

It's so slow with large assemblies !

Thanks,

--
Michel QUERIAUD
0 Likes
456 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
The technique you're currently using is the best way to do this. Indexing a
part by name was not previously supported because unique names were not
enforced for occurrences in an assembly. This changed in Inventor 7.
Inventor 8 will introduce a new property (ItemByName) on the
ComponentOccurrences object that will allow you to obtain a specific
occurrence given its name.
--
Brian Ekins
Developer Technical Services, Autodesk
Discussion Q&A: http://www.autodesk.com/discussion


"Michel QUERIAUD" wrote in message
news:8E9B8BDEEFA20E866EA0A72928CBAD6B@in.WebX.maYIadrTaRb...
> Hi,
>
> Is there an easiest way to select an occurence by it's name :
>
> Sub EraseOccurence(OccurenceName As String)
> Dim Occurence As ComponentOccurrence
>
> For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
> If Occurence.Name = OccurenceName Then
> Occurence.Visible = False
> Exit For
> End If
> Next Occurence
> End Sub
>
> It's so slow with large assemblies !
>
> Thanks,
>
> --
> Michel QUERIAUD
>
>
0 Likes
Message 3 of 7

Anonymous
Not applicable
YeHawwwwww 8^)

--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"Brian Ekins (Autodesk)" wrote in message

> Inventor 8 will introduce a new property (ItemByName) on the
> ComponentOccurrences object that will allow you to obtain a specific
> occurrence given its name.
0 Likes
Message 4 of 7

Anonymous
Not applicable
Will the ItemByName property (method?) return a "name path" to uniquely
identify a leaf component in a subassembly (which will have the same browser
name as the same leaf part in all subassembly occurrences), or will you need
to step through the ItemByName property up and down the hierarchy?

Thanks,
Neil



"Brian Ekins (Autodesk)" wrote in message
news:D2E34009255EE7699B87A1F7244FE87A@in.WebX.maYIadrTaRb...
> The technique you're currently using is the best way to do this. Indexing
a
> part by name was not previously supported because unique names were not
> enforced for occurrences in an assembly. This changed in Inventor 7.
> Inventor 8 will introduce a new property (ItemByName) on the
> ComponentOccurrences object that will allow you to obtain a specific
> occurrence given its name.
> --
> Brian Ekins
> Developer Technical Services, Autodesk
> Discussion Q&A: http://www.autodesk.com/discussion
>
>
> "Michel QUERIAUD" wrote in message
> news:8E9B8BDEEFA20E866EA0A72928CBAD6B@in.WebX.maYIadrTaRb...
> > Hi,
> >
> > Is there an easiest way to select an occurence by it's name :
> >
> > Sub EraseOccurence(OccurenceName As String)
> > Dim Occurence As ComponentOccurrence
> >
> > For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
> > If Occurence.Name = OccurenceName Then
> > Occurence.Visible = False
> > Exit For
> > End If
> > Next Occurence
> > End Sub
> >
> > It's so slow with large assemblies !
> >
> > Thanks,
> >
> > --
> > Michel QUERIAUD
> >
> >
>
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
sweet!

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
----------------------------------------------------------------------------
------
"Brian Ekins (Autodesk)" wrote in message
news:D2E34009255EE7699B87A1F7244FE87A@in.WebX.maYIadrTaRb...
> The technique you're currently using is the best way to do this. Indexing
a
> part by name was not previously supported because unique names were not
> enforced for occurrences in an assembly. This changed in Inventor 7.
> Inventor 8 will introduce a new property (ItemByName) on the
> ComponentOccurrences object that will allow you to obtain a specific
> occurrence given its name.
> --
> Brian Ekins
> Developer Technical Services, Autodesk
> Discussion Q&A: http://www.autodesk.com/discussion
>
>
> "Michel QUERIAUD" wrote in message
> news:8E9B8BDEEFA20E866EA0A72928CBAD6B@in.WebX.maYIadrTaRb...
> > Hi,
> >
> > Is there an easiest way to select an occurence by it's name :
> >
> > Sub EraseOccurence(OccurenceName As String)
> > Dim Occurence As ComponentOccurrence
> >
> > For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
> > If Occurence.Name = OccurenceName Then
> > Occurence.Visible = False
> > Exit For
> > End If
> > Next Occurence
> > End Sub
> >
> > It's so slow with large assemblies !
> >
> > Thanks,
> >
> > --
> > Michel QUERIAUD
> >
> >
>
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
It will return occurrences directly owned by the AssemblyComponentDefinition
you got the ComponentOccurrences object from. This means it will only
search that level of the assembly. It's also only within a single level
that unique names are guaranteed, so if it expanded beyond this then you
have those issues to contend with.
--
Brian Ekins
Developer Technical Services, Autodesk
Discussion Q&A: http://www.autodesk.com/discussion


"Neil Munro" wrote in message
news:DCA3C04EF2F9803997BF8EBAA3BCD403@in.WebX.maYIadrTaRb...
> Will the ItemByName property (method?) return a "name path" to uniquely
> identify a leaf component in a subassembly (which will have the same
browser
> name as the same leaf part in all subassembly occurrences), or will you
need
> to step through the ItemByName property up and down the hierarchy?
>
> Thanks,
> Neil
>
>
>
> "Brian Ekins (Autodesk)" wrote in message
> news:D2E34009255EE7699B87A1F7244FE87A@in.WebX.maYIadrTaRb...
> > The technique you're currently using is the best way to do this.
Indexing
> a
> > part by name was not previously supported because unique names were not
> > enforced for occurrences in an assembly. This changed in Inventor 7.
> > Inventor 8 will introduce a new property (ItemByName) on the
> > ComponentOccurrences object that will allow you to obtain a specific
> > occurrence given its name.
> > --
> > Brian Ekins
> > Developer Technical Services, Autodesk
> > Discussion Q&A: http://www.autodesk.com/discussion
> >
> >
> > "Michel QUERIAUD" wrote in message
> > news:8E9B8BDEEFA20E866EA0A72928CBAD6B@in.WebX.maYIadrTaRb...
> > > Hi,
> > >
> > > Is there an easiest way to select an occurence by it's name :
> > >
> > > Sub EraseOccurence(OccurenceName As String)
> > > Dim Occurence As ComponentOccurrence
> > >
> > > For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
> > > If Occurence.Name = OccurenceName Then
> > > Occurence.Visible = False
> > > Exit For
> > > End If
> > > Next Occurence
> > > End Sub
> > >
> > > It's so slow with large assemblies !
> > >
> > > Thanks,
> > >
> > > --
> > > Michel QUERIAUD
> > >
> > >
> >
> >
>
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
As expected, thanks Brian. This was a fairly big issue for a current
project.

Neil

"Brian Ekins (Autodesk)" wrote in message
news:BFDD675292343BC5EB40E61A5E4CF987@in.WebX.maYIadrTaRb...
> It will return occurrences directly owned by the
AssemblyComponentDefinition
> you got the ComponentOccurrences object from. This means it will only
> search that level of the assembly. It's also only within a single level
> that unique names are guaranteed, so if it expanded beyond this then you
> have those issues to contend with.
> --
> Brian Ekins
> Developer Technical Services, Autodesk
> Discussion Q&A: http://www.autodesk.com/discussion
>
>
> "Neil Munro" wrote in message
> news:DCA3C04EF2F9803997BF8EBAA3BCD403@in.WebX.maYIadrTaRb...
> > Will the ItemByName property (method?) return a "name path" to uniquely
> > identify a leaf component in a subassembly (which will have the same
> browser
> > name as the same leaf part in all subassembly occurrences), or will you
> need
> > to step through the ItemByName property up and down the hierarchy?
> >
> > Thanks,
> > Neil
> >
> >
> >
> > "Brian Ekins (Autodesk)" wrote in message
> > news:D2E34009255EE7699B87A1F7244FE87A@in.WebX.maYIadrTaRb...
> > > The technique you're currently using is the best way to do this.
> Indexing
> > a
> > > part by name was not previously supported because unique names were
not
> > > enforced for occurrences in an assembly. This changed in Inventor 7.
> > > Inventor 8 will introduce a new property (ItemByName) on the
> > > ComponentOccurrences object that will allow you to obtain a specific
> > > occurrence given its name.
> > > --
> > > Brian Ekins
> > > Developer Technical Services, Autodesk
> > > Discussion Q&A: http://www.autodesk.com/discussion
> > >
> > >
> > > "Michel QUERIAUD" wrote in message
> > > news:8E9B8BDEEFA20E866EA0A72928CBAD6B@in.WebX.maYIadrTaRb...
> > > > Hi,
> > > >
> > > > Is there an easiest way to select an occurence by it's name :
> > > >
> > > > Sub EraseOccurence(OccurenceName As String)
> > > > Dim Occurence As ComponentOccurrence
> > > >
> > > > For Each Occurence In oAsmDoc.ComponentDefinition.Occurrences
> > > > If Occurence.Name = OccurenceName Then
> > > > Occurence.Visible = False
> > > > Exit For
> > > > End If
> > > > Next Occurence
> > > > End Sub
> > > >
> > > > It's so slow with large assemblies !
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > Michel QUERIAUD
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes