Rule to Set Origin indicator on Drawing View

Rule to Set Origin indicator on Drawing View

Mac_W
Contributor Contributor
1,837 Views
20 Replies
Message 1 of 21

Rule to Set Origin indicator on Drawing View

Mac_W
Contributor
Contributor

I am trying to set the origin indicator on a drawing view in an IDW file. The rule i wrote below works if the two lines actually intersect. The issue is when the lines come to a radius instead of a vertex. Is there a way to get the theoretical intersection? Alternatively could I get the x value of one line, the y value of the other, and combine them to a point that I can set the origin to? Any advice or help would be greatly appreciated, also open to any suggestions if there is a better way to set the origin indicator from the drawing view. 

 

 

Sub Main()

	'Get the active sheet
	Dim oSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet

	'Get the curves for intersection point
	Dim oCurve1 As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick first intersection curve").Parent
	Dim oCurve2 As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick second intersection curve").Parent
	
	'Create GeometryIntent for intersection
	Dim oIntersectionIntent As GeometryIntent = oSheet.CreateGeometryIntent(oCurve1, oCurve2)

	Dim oDrawingView As DrawingView = oCurve1.Parent
	
	'If origin indicator has Not been already created, create it first.
	If Not oDrawingView.HasOriginIndicator Then
	    MsgBox("no origin indicator")
	    oDrawingView.CreateOriginIndicator(oIntersectionIntent)
	Else
		 MsgBox("has origin indicator")
		oDrawingView.OriginIndicator.Intent = oIntersectionIntent
	End If

End Sub

 

0 Likes
Accepted solutions (1)
1,838 Views
20 Replies
Replies (20)
Message 21 of 21

WCrihfield
Mentor
Mentor

Wow, I must just be trying to do too many things at the same time. 🙄  I forgot to 'return' the List(Of Inventor.GeometryIntent) object at the end of the custom function.  It needs a line like:

 

Return oGIs

 

...in there, just before End Function line.  That's the type of stuff that happens when you don't test code before posting it. 😏

 

Edit:  I attached the text file of the whole rule, with those two errors fixed, just for reference.  I tested it this time, and it seemed to work OK for me.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes