Assign name for faces in selectset

Assign name for faces in selectset

ngocson8335
Advocate Advocate
1,084 Views
4 Replies
Message 1 of 5

Assign name for faces in selectset

ngocson8335
Advocate
Advocate

Hello Everyone,

 

I would like to assign name for selected faces in selectset. I am using vb.net. Is there any code to do it?

 

Many thanks.

Ngoc Son
Autodesk User
0 Likes
Accepted solutions (1)
1,085 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

Could you please be a little more specific in what you try to do?

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

ngocson8335
Advocate
Advocate

Hi Mr. Arthur,

Thanks for your reply.

I would like to assign a name for all selected faced in the selectset as the following screenshot:

Selected Faces.png

 

Named.png

My code works but it is stoped after named for only one face. ???

        g_inventorApplication = Marshal.GetActiveObject("Inventor.Application")
        _partDoc = g_inventorApplication.ActiveDocument
        Dim _partDef As Inventor.ComponentDefinition
        _partDef = _partDoc.ComponentDefinition
        Dim _selectSet As Inventor.SelectSet
        _selectSet = _partDoc.SelectSet
        For i = 1 To _selectSet.Count
            Dim _selectedFace As Inventor.Face
            _selectedFace = _objectCollection.Item(i)

            Dim iLogicAddinGuid As String = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}"

            Dim _addin As Inventor.ApplicationAddIn
            _addin = g_inventorApplication.ApplicationAddIns.ItemById(iLogicAddinGuid)

            Dim _iLogicAuto As Object
            _iLogicAuto = _addin.Automation

            Dim _nameEntities As Object
            _nameEntities = _iLogicAuto.GetNamedEntities(_partDoc)

            Call _nameEntities.SetName(_selectedFace, "Face_" & i)

        Next

Many thanks.

 

Ngoc Son
Autodesk User
0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor
Accepted solution

One problem with your code is that I don't where the _objectCollection variable defined.  

 

Also, a select set is a somewhat fragile thing.  Making any changes to the model will usually clear the selection.  That's why you can create one but then it fails after that because the selection set is empty.  To avoid this issue you can first save all of the selected entities in a list or array and then iterate over that.  You can do something like what's shown below.

 

Dim faceList As New List(Of Face)
For Each fc As Face In _selectSet
    faceList.Add(fc)
Next

For Each fc As Face In faceList
    ' Do something with each face.
Next
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 5

ngocson8335
Advocate
Advocate

Hi Mr. BrianEkin,

 

I have tested and did the same code that you gave me. But it still has the same problem. It is stopped after 1 face. 

 

Can you help me with this?

 

screenshot_1577693294.png

Ngoc Son
Autodesk User
0 Likes