Is it possible to customize the basic operations of inventor?

Is it possible to customize the basic operations of inventor?

Miguel.CarvajalS34Q6
Advocate Advocate
408 Views
3 Replies
Message 1 of 4

Is it possible to customize the basic operations of inventor?

Miguel.CarvajalS34Q6
Advocate
Advocate

hello,
It is to generate a code that differentiates me from the basic operations of Invetor, for example: extrusions, rounding, holes, chamfer, etc.
and give the operation a color, to identify the different operations that each model has.

thanks.

0 Likes
Accepted solutions (2)
409 Views
3 Replies
Replies (3)
Message 2 of 4

Frederick_Law
Mentor
Mentor

It will be a very long code.

An addin that watch every command IV use and change color for each command.

You'll need to find name for each command and decide which color for each command.

And it could slow down IV because something need to be done for each command.

 

This will list all commands:

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-902D34CA-4543-436C-AFF3-83F3386A2FD1

 

There are over 3000 commands.

Every time a command start, the code will check command name and see if it need to change color.

The event is: UserInputEvents.OnActivateCommand

0 Likes
Message 3 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

If you want just analyze existing model, you can use this simple code to change color.

This code expects the appropriate color assets exists in part document

 

Sub Main()
    Dim part As PartDocument = ThisDoc.Document
    Dim partDef As PartComponentDefinition = part.ComponentDefinition

    
    For Each surfaceBody As SurfaceBody In partDef.SurfaceBodies
        For Each face As Face In surfaceBody.Faces
            Dim color As Asset
            Select Case face.CreatedByFeature.Type
                Case ObjectTypeEnum.kExtrudeFeatureObject
                    color = part.AppearanceAssets("Extrude") 
                Case ObjectTypeEnum.kRevolveFeatureObject
                    color = part.AppearanceAssets("Revolve")
                Case ObjectTypeEnum.kHoleFeatureObject
                    color = part.AppearanceAssets("Hole")
                Case ObjectTypeEnum.kFilletFeatureObject
                    color = part.AppearanceAssets("Fillet")
                Case ObjectTypeEnum.kChamferFeatureObject
                    color = part.AppearanceAssets("Chamfer")
                    'Etc.
                Case Else
                    Continue For
            End Select

            face.Appearance = color

        Next
    Next
End Sub
Message 4 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

Another approach is to use HighlightSets. This solution only temporarily change color in active view and doesn't modify part document

 

Sub main
	HighlightFaceByFeature()
End Sub

Private Sub HighlightFaceByFeature()

	Dim part As PartDocument = ThisDoc.Document
	Dim partDef As PartComponentDefinition = part.ComponentDefinition

	Dim extrudeFaces As HighlightSet = part.CreateHighlightSet()
	Dim revolveFaces As HighlightSet = part.CreateHighlightSet()
	Dim holeFaces As HighlightSet = part.CreateHighlightSet()
	Dim filletFaces As HighlightSet = part.CreateHighlightSet()
	Dim chamferFaces As HighlightSet = part.CreateHighlightSet()

	extrudeFaces.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
	revolveFaces.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
	holeFaces.Color = ThisApplication.TransientObjects.CreateColor(0, 0, 255)
	filletFaces.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 0)
	chamferFaces.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 255)


	For Each SurfaceBody As SurfaceBody In partDef.SurfaceBodies
		For Each Face As Face In SurfaceBody.Faces
			Select Case Face.CreatedByFeature.Type
				Case ObjectTypeEnum.kExtrudeFeatureObject
					extrudeFaces.AddItem(Face)
				Case ObjectTypeEnum.kRevolveFeatureObject
					revolveFaces.AddItem(Face)
				Case ObjectTypeEnum.kHoleFeatureObject
					holeFaces.AddItem(Face)
				Case ObjectTypeEnum.kFilletFeatureObject
					filletFaces.AddItem(Face)
				Case ObjectTypeEnum.kChamferFeatureObject
					chamferFaces.AddItem(Face)
					'Etc.
				Case Else
					Continue For
			End Select
		Next
	Next
End Sub

 

To clear preview you can use this code

Dim part As PartDocument = ThisDoc.Document
For Each hs As HighlightSet In part.Highlightsets
	hs.Delete()
Next
part.Update

 

0 Likes