Selecting individual drawing curve in drawing view

Selecting individual drawing curve in drawing view

breinkemeyer
Enthusiast Enthusiast
580 Views
5 Replies
Message 1 of 6

Selecting individual drawing curve in drawing view

breinkemeyer
Enthusiast
Enthusiast

Working on automating drawings.  To learn I have drawn a simple square so there are 4 Drawing curves in the drawing curves collection.  to add the point for the dimension I intend to loop thru the curves and find one where the endpoint or the start point matches a known point.  I would like to add the dimension between two points.  Could someone point me in the right direction?  Working in C#, but examples in vb or vba will work.

0 Likes
581 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @breinkemeyer.  Automating drawings can be a large and complicated task.  There are often multiple ways to do a lot of the things involved too.  I'm not sure exactly how you intend to check if these points are the 'known point' you are looking for, but I included one process that came to mind in the below example.  This is an iLogic rule, but since iLogic uses VB.NET and I don't think I'm using any iLogic only snippets of code here, this should work OK in other settings too.  I made sure not to use the common 'ThisApplication' or 'ThisDoc' types of keywords, because I know they are iLogic tools.  See if this helps you.

 

Dim oInv As Inventor.Application = GetObject(,"Inventor.Application")
Dim oDDoc As DrawingDocument = oInv.ActiveDocument
oSheet = oDDoc.ActiveSheet
oView = oSheet.DrawingViews.Item(1)
oTG = oInv.TransientGeometry

'the 'known point' locations you are looking for
oKnownPoint1 = oTG.CreatePoint2d(2, 6)
oKnownPoint2 = oTG.CreatePoint2d(2, 8)

Dim oIntent1, oIntent2 As GeometryIntent
For Each oDCurve As DrawingCurve In oView.DrawingCurves
	If oDCurve.CurveType = CurveTypeEnum.kLineCurve Or _
		oDCurve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
		If oDCurve.StartPoint.IsEqualTo(oKnownPoint) Then
			oIntent1 = oSheet.CreateGeometryIntent(oDCurve, oDCurve.StartPoint)
		ElseIf oDCurve.EndPoint.IsEqualTo(oKnownPoint) Then
			oIntent1 = oSheet.CreateGeometryIntent(oDCurve, oDCurve.EndPoint)
		ElseIf oDCurve.StartPoint.IsEqualTo(oKnownPoint2) Then
			oIntent2 = oSheet.CreateGeometryIntent(oDCurve, oDCurve.StartPoint)
		ElseIf oDCurve.EndPoint.IsEqualTo(oKnownPoint2) Then
			oIntent2 = oSheet.CreateGeometryIntent(oDCurve, oDCurve.EndPoint)
		End If
	End If
Next
If Not IsNothing(oIntent1) And Not IsNothing(oIntent2) Then
	oTextPoint = oTG.CreatePoint2d(1.5, 7)
	oGenDims = oSheet.DrawingDimensions.GeneralDimensions
	oDim1 = oGenDims.AddLinear(oTextPoint, oIntent1, oIntent2, DimensionTypeEnum.kVerticalDimensionType)
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

breinkemeyer
Enthusiast
Enthusiast

Thank you for your reply.  You're right, it's very complicated.  I've done it for Solid Edge.  for that I searched for start or end points of the element at the known point.  it then returns a reference to the element in the drawing view.  this allowed the dimensions to be associative to the model.  Currently in Inventor I'm adding work points in the assembly and converting them to sheet points in the draft.  Using functions to simplify it, but I don't think that's the ultimate answer.    

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

From the sounds of what you're saying, there is also tools similar sounding to that in Inventor too.  This 'known point'...are we talking about a point within the model space or a point within the 'sheet' space.  There are tools (methods) located under the PartComponentDefinition like FindUsingPoint, FindUsingRay, & FindUsingVector, but that is for model space.  There is also a tool under the DrawingView where you can specify a feature or other entity from model space and have it either projected to a point in the DrawingView or you can put it as input after the DrawingView.DrawingCurves(oObject) to get the set of DrawingCurves it represents in the view.  Do any of those tools sound right to you.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

breinkemeyer
Enthusiast
Enthusiast

Yes, the known point is a point on the model.  I can use modeltoview and viewtosheet to find the element in the drawing view.  I see that inventor has similar methods.  the nice thing about SE is that in the drawing view the elements are broken up into DVLines,  DVArcs and DVCircles.  

 

There is also a tool under the DrawingView where you can specify a feature or other entity from model space and have it either projected to a point in the DrawingView or you can put it as input after the DrawingView.DrawingCurves(oObject) to get the set of DrawingCurves it represents in the view.  Do any of those tools sound right to you.

 

this sounds right for sure.  the two API's are very similar, just different wording.  Unfortunately I have 20 Years working with Solid Edge and about a year in Inventor.  It's like re-learning everything again.  I'll get to work with your info and see what I can come up with.  It sure would be nice if all our engineering departments would use the same software.

0 Likes
Message 6 of 6

JelteDeJong
Mentor
Mentor

On my blog I have an example of an iLogic rule that loops over all drawing curves, in a DrawingView, and finds the most top and bottom point/intent and adds a dimension between the points/intents. And does the same for the most left and right point of a DrawingView.

I think that this is more or less similar to what you are trying to do. You can find it here: http://hjalte.nl/37-auto-overall-dimension . (If you like that there is also another post that adds dimensions and center lines for holes. Using more almost the same technique.)

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