HighlightSet of DimensionConstraint Entities

J-Camper
Advisor

HighlightSet of DimensionConstraint Entities

J-Camper
Advisor
Advisor

I'm trying to build a troubleshooting tool to help figure out how DimensionConstraints were set up in existing sketches from others.  I'm trying to get a HighlightSet to mimic what you see on creation of DimensionConstraints:

Example: Creation Higlights to mimicExample: Creation Higlights to mimic

I tried to make a generic script to cover all DimensionConstraints, but I can't get the HighlightSet to work:

 

Sub Main
Dim dimension As DimensionConstraint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a sketch dimension") If IsNothing(dimension) Then Exit Sub ' If nothing gets selected then we're done ' Dim readableType As String = SelectCase(dimension.Type) 'separate function to provide readable object type information Dim Anchors As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection : Anchors = dimension.AnchorPoints Dim selectThis As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet 'Cycle attempt: ' For i = 1 To Anchors.Count ' selectThis.AddItem(Anchors.Item(i)) ' Next 'Batch Attempt ' selectThis.AddMultipleItems(Anchors) 'Hardcode Test ' selectThis.AddItem(Anchors.Item(1)) 'Batch Attempt through function with cycle ' selectThis.AddMultipleItems(SelectObjects(Anchors))
End Sub

All the routes I have tried return the same error:

 

 

System.NotImplementedException: Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.HighlightSet.AddMultipleItems(ObjectCollection Entities)
   at ThisRule.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

Do I need to dig deeper than the AnchorPoints?  Am I going to have to handle each DimensionConstraint type differently for the type of Sketch entities used to create them?  Is it even possible to back trace these highlighted entities from existing DimensionConstraints?

 

0 Likes
Reply
435 Views
3 Replies
Replies (3)

J-Camper
Advisor
Advisor

Well I think I answered my own questions.  Anchor points are not related to the objects selected when making the DimensionConstraint, and I will have to set up cases for each type of DimensionConstraint and their respective Proxies in order to get their entities.

 

Unless someone knows of a way to do this in a more generic way, I will accept this response as a solution in a couple days.  Still holding out hope that it is possible to do from a generic DimensionConstraint.

0 Likes

JelteDeJong
Mentor
Mentor

The Anchors property gives 2 times a 2Dpoint. That are coodinates of a point (not points that you can select.) Therfore a selection set will not work. The problem I found is that the general object DimensionConstraint only has properties with 2DPoints. Therefor i think you shouldn't use that object but you should look closer what kind of object is selected and then take the correct steps. try this iLogic rule.

Dim dimension = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a sketch dimension")
Dim selectThis As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet

If (dimension.Type = ObjectTypeEnum.kOffsetDimConstraintObject) Then
    Dim d As OffsetDimConstraint = dimension
    selectThis.Color = ThisApplication.TransientObjects.CreateColor(0, 0, 255)
    selectThis.AddItem(dimension.Entity)
    selectThis.AddItem(dimension.Line)
End If

MsgBox("Have a look at the HighlightSet. (It will be gone when you click on ok.)")

this is my result.

selctionset.png

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

J-Camper
Advisor
Advisor

Yeah I came to a similar result yesterday after making this post.  I was able to leave to dimension as a generic DimensionConstraint and just treat it differently depending on the type, after I checked it.  The longest part was compiling my Case Lists in the Functions, here was my result:

Sub Main
	Dim selectThis As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet : selectThis.Color = ThisApplication.TransientObjects.CreateColor(255, 100, 100)
10 :
	Dim dimension As DimensionConstraint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a sketch dimension")
	If IsNothing(dimension) Then Exit Sub ' If nothing gets selected then we're done
	Dim readableType As String = SelectCase(dimension.Type)
	selectThis.AddMultipleItems(SelectObjects(readableType, dimension))
	If MessageBox.Show("Type:   " & readableType & vbCrLf & vbCrLf & _
					"Parameter Name:  " & dimension.Parameter.Name & "  Is driven?  " & dimension.Driven & vbCrLf & vbCrLf & _
					"Exists in Sketch:  " & dimension.Parent.Name & vbCrLf & vbCrLf & _
					"Entities used to define are now highlighted on screen." & vbCrLf & vbCrLf & _
					"Would you like to check information of another Dimension Constraint?", "Dimension Constraint Info:", MessageBoxButtons.YesNo) = vbYes Then selectThis.Clear : GoTo 10 Else selectThis.Clear
End Sub

Function SelectObjects(DimType As String, DimConstraint As DimensionConstraint) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Select Case DimType
		Case "kArcLengthDimConstraintObject", "kArcLengthDimConstraintProxyObject", "kDiameterDimConstraintObject", "kDiameterDimConstraintProxyObject", _
			 "kEllipseRadiusDimConstraintObject", "kEllipseRadiusDimConstraintProxyObject", "kRadiusDimConstraintObject", "kRadiusDimConstraintProxyObject"
			Result.Add(DimConstraint.Entity)
		Case "kOffsetDimConstraintObject", "kOffsetDimConstraintProxyObject"
			Result.Add(DimConstraint.Entity)
			Result.Add(DimConstraint.Line)
		Case "kOffsetSplineDimConstraintObject", "kOffsetSplineDimConstraintProxyObject"
			Result.Add(DimConstraint.OffsetSpline)
			Result.Add(DimConstraint.Spline)
		Case "kTangentDistanceDimConstraintObject", "kTangentDistanceDimConstraintProxyObject"
			Result.Add(DimConstraint.EntityOne)
			Result.Add(DimConstraint.EntityTwo)
		Case "kThreePointAngleDimConstraintObject", "kThreePointAngleDimConstraintProxyObject"
			Result.Add(DimConstraint.PointOne)
			Result.Add(DimConstraint.PointTwo)
			Result.Add(DimConstraint.PointThree)
		Case "kTwoLineAngleDimConstraintObject", "kTwoLineAngleDimConstraintProxyObject"
			Result.Add(DimConstraint.LineOne)
			Result.Add(DimConstraint.LineTwo)
		Case "kTwoPointDistanceDimConstraintObject", "kTwoPointDistanceDimConstraintProxyObject"
			Result.Add(DimConstraint.PointOne)
			Result.Add(DimConstraint.PointTwo)
	End Select
	Return Result
End Function

Function SelectCase(check As Double) As String
	'NOTES:
		'Dimension Constraint Types: ArcLengthDimConstraint, DiameterDimConstraint, EllipseRadiusDimConstraint, OffsetDimConstraint, OffsetSplineDimConstraint, RadiusDimConstraint, TangentDistanceDimConstraint, ThreePointAngleDimConstraint, TwoLineAngleDimConstraint, TwoPointDistanceDimConstraint
		'Dimension Constraint Types: 84014336 [84014448]   , 83906560 [83906672]  , 83924224 [83924336]       , 83905536 [83905648], 83972608 [83972720]      , 83906816 [83906928], 83907072 [83907184]         , 83906304 [83906416]         , 83906048 [83906160]      , 83905792 [83905904]
		'                             Actual    [Proxy]
	Result = "Type Not Found..."
	Select Case check
		Case 84014336
			Result = "kArcLengthDimConstraintObject"
		Case 84014448
			Result = "kArcLengthDimConstraintProxyObject"
		Case 83906560
			Result = "kDiameterDimConstraintObject"
		Case 83906672
			Result = "kDiameterDimConstraintProxyObject"	
		Case 83924224
			Result = "kEllipseRadiusDimConstraintObject"
		Case 84014448
			Result = "kEllipseRadiusDimConstraintProxyObject"
		Case 83905536
			Result = "kOffsetDimConstraintObject"
		Case 83905648
			Result = "kOffsetDimConstraintProxyObject"	
		Case 83972608
			Result = "kOffsetSplineDimConstraintObject"
		Case 83972720
			Result = "kOffsetSplineDimConstraintProxyObject"
		Case 83906816
			Result = "kRadiusDimConstraintObject"
		Case 83906928
			Result = "kRadiusDimConstraintProxyObject"	
		Case 83907072
			Result = "kTangentDistanceDimConstraintObject"
		Case 83907184
			Result = "kTangentDistanceDimConstraintProxyObject"
		Case 83906304
			Result = "kThreePointAngleDimConstraintObject"
		Case 83906416
			Result = "kThreePointAngleDimConstraintProxyObject"
		Case 83906048
			Result = "kTwoLineAngleDimConstraintObject"
		Case 83906160
			Result = "kTwoLineAngleDimConstraintProxyObject"
		Case 83905792
			Result = "kTwoPointDistanceDimConstraintObject"
		Case 83905904
			Result = "kTwoPointDistanceDimConstraintProxyObject"
	End Select
	Return Result
End Function

I think it's a useful troubleshooting tool especially for digging into old sketches or sketches done by someone else. 

0 Likes