Hi all, does anyone know the code to highlight face like in this picture
If you know any solution, please help me
Thank you so much
Solved! Go to Solution.
Hi all, does anyone know the code to highlight face like in this picture
If you know any solution, please help me
Thank you so much
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by WCrihfield. Go to Solution.
Here is a very simple iLogic rule that should do what you want:
Dim oDoc As Document = ThisDoc.Document
Dim oSS As SelectSet = oDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oDoc.CreateHighlightSet()
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a part face to highlight.")
oSS.Select(oFace)
oHSet.AddItem(oFace)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
Here is a very simple iLogic rule that should do what you want:
Dim oDoc As Document = ThisDoc.Document
Dim oSS As SelectSet = oDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oDoc.CreateHighlightSet()
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a part face to highlight.")
oSS.Select(oFace)
oHSet.AddItem(oFace)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
Or if you don't want to manually select the face, there are a couple other options.
Option one: you could simply specify the face by its index number on the solid body (if you know which one it was).
Option two: assign a name to the face in the model, then identify and get the face by that name using the NamedEntities technique.
Here's an example of Option one:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSS As SelectSet = oPDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oBody As SurfaceBody = oPDef.SurfaceBodies.Item(1)
Dim oFace As Face = oBody.Faces.Item(1)
oSS.Select(oFace)
oHSet.AddItem(oFace)
And here is an example of Option two:
(Keep in mind this won't work unless you have assigned that face a name in your model, and the name matches the name specified within the code.)
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oNE As NamedEntities = iLogicVb.Automation.GetNamedEntities(oPDoc)
Dim oSS As SelectSet = oPDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oFace As Face = oNE.TryGetEntity("Top Face")
oSS.Select(oFace)
oHSet.AddItem(oFace)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Or if you don't want to manually select the face, there are a couple other options.
Option one: you could simply specify the face by its index number on the solid body (if you know which one it was).
Option two: assign a name to the face in the model, then identify and get the face by that name using the NamedEntities technique.
Here's an example of Option one:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSS As SelectSet = oPDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oBody As SurfaceBody = oPDef.SurfaceBodies.Item(1)
Dim oFace As Face = oBody.Faces.Item(1)
oSS.Select(oFace)
oHSet.AddItem(oFace)
And here is an example of Option two:
(Keep in mind this won't work unless you have assigned that face a name in your model, and the name matches the name specified within the code.)
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oNE As NamedEntities = iLogicVb.Automation.GetNamedEntities(oPDoc)
Dim oSS As SelectSet = oPDoc.SelectSet
oSS.Clear
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oFace As Face = oNE.TryGetEntity("Top Face")
oSS.Select(oFace)
oHSet.AddItem(oFace)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @WCrihfield
Very thank for you help
Hi @WCrihfield
Very thank for you help
HI @WCrihfield
I have tried your method
As I see the HightSet is changing the color of my selected face and it doesn't come back to the normal when I stop select
I just when to highlight it in the sort time, and I wanna choose multi faces with Pick method
If you have other solution, please help me, thank you
HI @WCrihfield
I have tried your method
As I see the HightSet is changing the color of my selected face and it doesn't come back to the normal when I stop select
I just when to highlight it in the sort time, and I wanna choose multi faces with Pick method
If you have other solution, please help me, thank you
Since I don't really know yet what you are wanting to do with the faces after they are selected, I'm showing three different processes here that all use the Pick function.
FYI:
- The document's SelectSet is where objects are normally temporarily stored when they are selected manually, or by the SelectSet.Select or SelectSet.SelectMultiple methods in code.
- As far as I know, the document's HighlightSet is purely for visual aid purposes, and is not necessary to use for normal selection purposes when selecting things by code.
- The ObjectCollection is a very handy object used to store all types of objects temporarily in a single variable, so they can either all be acted on at once later, or so they can be looped through later in some other process.
So, depending on your purpose for selecting the faces, you may not need all of these in the following code, but I have included them to show you how to create them and add to them. Here's the new rule:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
'if you have selected anything prior to starting this rule
'those things will be in this document's SelectSet
Dim oSelected As SelectSet = oPDoc.SelectSet
'clearing this set
oSelected.Clear
Dim oFaceCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oFace As Face
'the following word is a location marker for the GoTo method below
Repeat :
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a part face.")
If oFace IsNot Nothing Then
'add the Face to the 'actively selected' set of your document
oSelected.Select(oFace)
'add the Face to an ObjectCollection so you can work with them as a group later
oFaceCollection.Add(oFace)
'add the Face to the document's HighlightSet (visual aid only)
oHSet.AddItem(oFace)
'telling it to go back to where I inserted the word "Repeat", just before the Pick command
'so it will continue to Pick more faces until Nothing is selected
GoTo Repeat
Else
'do nothing, just continue the rule
End If
'now all the Faces you selected are in those sets
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Since I don't really know yet what you are wanting to do with the faces after they are selected, I'm showing three different processes here that all use the Pick function.
FYI:
- The document's SelectSet is where objects are normally temporarily stored when they are selected manually, or by the SelectSet.Select or SelectSet.SelectMultiple methods in code.
- As far as I know, the document's HighlightSet is purely for visual aid purposes, and is not necessary to use for normal selection purposes when selecting things by code.
- The ObjectCollection is a very handy object used to store all types of objects temporarily in a single variable, so they can either all be acted on at once later, or so they can be looped through later in some other process.
So, depending on your purpose for selecting the faces, you may not need all of these in the following code, but I have included them to show you how to create them and add to them. Here's the new rule:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
'if you have selected anything prior to starting this rule
'those things will be in this document's SelectSet
Dim oSelected As SelectSet = oPDoc.SelectSet
'clearing this set
oSelected.Clear
Dim oFaceCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oHSet As HighlightSet = oPDoc.CreateHighlightSet()
Dim oFace As Face
'the following word is a location marker for the GoTo method below
Repeat :
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a part face.")
If oFace IsNot Nothing Then
'add the Face to the 'actively selected' set of your document
oSelected.Select(oFace)
'add the Face to an ObjectCollection so you can work with them as a group later
oFaceCollection.Add(oFace)
'add the Face to the document's HighlightSet (visual aid only)
oHSet.AddItem(oFace)
'telling it to go back to where I inserted the word "Repeat", just before the Pick command
'so it will continue to Pick more faces until Nothing is selected
GoTo Repeat
Else
'do nothing, just continue the rule
End If
'now all the Faces you selected are in those sets
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.