Message 1 of 3
Constraint Occurences flashing with highlight set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Guys,
I've found this usefull rule to get the occurences and their enitys.
Gelöst: Find Entities - Autodesk Community - Inventor
How could the highlight set be used to get the Occurence1, Enity1, Occurence2, Enity2 flashing alternately instead of the text box?
Nice would be also if the Occurence/Enity names show up in the status bar while its Highlighted.
Sub Main If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "") Exit Sub End If Dim oADoc As AssemblyDocument = ThisDoc.Document Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition Dim oOccs As ComponentOccurrences = oADef.Occurrences Dim oConsts As AssemblyConstraints = oADef.Constraints For Each oConst As AssemblyConstraint In oConsts 'if the constraint is suppressed, then skip to next constraint 'can't access/do much with a suppressed constraint If oConst.Suppressed Then Continue For Dim oOcc1 As ComponentOccurrence = oConst.OccurrenceOne Dim oOcc2 As ComponentOccurrence = oConst.OccurrenceTwo Dim oEnt1 As Object = oConst.EntityOne Dim oEnt2 As Object = oConst.EntityTwo Dim oGeom1 As Object = oConst.GeometryOne Dim oGeom2 As Object = oConst.GeometryTwo 'some types of constraints do not return a parameter, so below may = Nothing Dim oParam As Inventor.Parameter = GetParamFromConstraint(oConst) Dim oParamName As String = "" Dim oParamExp As String = "" If oParam IsNot Nothing Then oParamName = oParam.Name oParamExp = oParam.Expression End If Dim oReport As String = "Constraint Name: " & oConst.Name oReport = oReport & vbCrLf & "Constraint Type: " & TypeName(oConst) oReport = oReport & vbCrLf & "Component 1 Name: " & oOcc1.Name oReport = oReport & vbCrLf & "Component 2 Name: " & oOcc2.Name oReport = oReport & vbCrLf & "Entity 1 Type: " & TypeName(oEnt1) oReport = oReport & vbCrLf & "Entity 2 Type: " & TypeName(oEnt2) oReport = oReport & vbCrLf & "Geometry 1 Type: " & TypeName(oGeom1) oReport = oReport & vbCrLf & "Geometry 2 Type: " & TypeName(oGeom2) oReport = oReport & vbCrLf & "Controlling Parameter Name: " & oParamName oReport = oReport & vbCrLf & "Controlling Parameter Expression: " & oParamExp MsgBox(oReport, vbInformation, "Constraint Information") Next End Sub Function GetParamFromConstraint(oConst As AssemblyConstraint) As Inventor.Parameter Dim oParam As Inventor.Parameter = Nothing If TypeOf oConst Is AngleConstraint Then Dim oAngleConstraint As AngleConstraint = oConst oParam = oAngleConstraint.Angle ElseIf TypeOf oConst Is FlushConstraint Then Dim oFlushConstraint As FlushConstraint = oConst oParam = oFlushConstraint.Offset ElseIf TypeOf oConst Is InsertConstraint Then Dim oInsertConstraint As InsertConstraint = oConst oParam = oInsertConstraint.Distance ElseIf TypeOf oConst Is MateConstraint Then Dim oMateConstraint As MateConstraint = oConst oParam = oMateConstraint.Offset ElseIf TypeOf oConst Is RotateRotateConstraint Then Dim oRotateRotateConstraint As RotateRotateConstraint = oConst oParam = oRotateRotateConstraint.Ratio ElseIf TypeOf oConst Is RotateTranslateConstraint Then Dim oRotateTranslateConstraint As RotateTranslateConstraint = oConst oParam = oRotateTranslateConstraint.Distance ElseIf TypeOf oConst Is AssemblySymmetryConstraint Then Dim oAssemblySymmetryConstraint As AssemblySymmetryConstraint = oConst 'there is no Parameter involved with this type of constraint ElseIf TypeOf oConst Is TangentConstraint Then Dim oTangentConstraint As TangentConstraint = oConst oParam = oTangentConstraint.Offset ElseIf TypeOf oConst Is TransitionalConstraint Then Dim oTransitionalConstraint As TransitionalConstraint = oConst 'there is no Parameter involved with this type of constraint End If Return oParam End Function