Drawing automation using attribute helper

Drawing automation using attribute helper

Anonymous
Not applicable
1,020 Views
3 Replies
Message 1 of 4

Drawing automation using attribute helper

Anonymous
Not applicable

Hi,

 

I am working on Inventor drawing automation using attribute helper as below.

 

  1. Using attribute helper I am creating attributes for dimension X and Y position.
  2. Through API I am reading the attributes for each dimension in drawing.
  3. Once I have the X and Y position attribute I am getting the dimension view name using "oView = oLinDim.IntentOne.Geometry.Parent;"
  4. Once I get the view name, I have the view origin.
  5. Using view origin I am placing the dimension text position relative to view origin. 
  6. This is working fine for dimension that has curve as IntentOne or IntentTwo.

My issue is with Dimensions that have centerline as IntentOne and IntentTwo. I am not able to get the view name for Dimensions that are created using centerline.

 

Please share your idea on my approach and issue I am facing with dimension created using centerline.

 

0 Likes
1,021 Views
3 Replies
Replies (3)
Message 2 of 4

JhoelForshav
Mentor
Mentor

Hi @Anonymous 

I gave it a go to create a function that takes a centerline as argument and goes through the views of the same sheet as this centerline to see if the centerline is inside the borders of any view on the sheet. Maybe there are better approaches to this problem but ran some tests and it seems to work 🙂

 

iLogic code:

Sub Main
	Dim oCL As Centerline = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCenterlineFilter, "")
	Dim oView As DrawingView = GetView(oCL)
	MsgBox(oView.Name)
End Sub

Function GetView(oCL As Centerline) As DrawingView
	For Each oView As DrawingView In oCL.Parent.DrawingViews
		If LineInView(oView, oCL) Then Return oView
	Next
	Return Nothing
End Function

Function LineInView(oView As DrawingView, oCL As Centerline)
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oBox As Box2d = oTG.CreateBox2d
	oBox.MaxPoint = oTG.CreatePoint2d(oView.Center.X + oView.Width / 2, oView.Top)
	oBox.MinPoint = oTG.CreatePoint2d(oView.Center.X - oView.Width / 2, oView.Top - oView.Height)
	Dim oGeo = oCL.Geometry
	oEvaluator = oGeo.Evaluator
	Dim oMinP, oMaxP As Double
	oEvaluator.GetParamExtents(oMinP, oMaxP)
	Dim dLen As Double
	Call oEvaluator.GetLengthAtParam(oMinP, oMaxP, dLen)
	Dim dInc As Double
	dInc = dLen / 100  'consider 100 points         
	Dim dparams(0) As Double
	dparams(0) = oMinP
	Dim iCnt As Integer
	For iCnt = 0 To 100
		Dim dParam As Double
		Call oEvaluator.GetParamAtLength(oMinP,
		dInc * iCnt,
		dParam)
		Dim dPts(1) As Double
		dparams(0) = dParam
		Call oEvaluator.GetPointAtParam(dparams, dPts)
		Dim oPoint As Point2d = oTG.CreatePoint2d(dPts(0), dPts(1))
		If oBox.Contains(oPoint) Then
			Return True
		End If
	Next
	Return False
End Function
Message 3 of 4

Anonymous
Not applicable

Jhoel Forshav,

 

Thank you for sharing your approach. I have also thought about it. As you said wanted to know if there are any better approach.

 

0 Likes
Message 4 of 4

JhoelForshav
Mentor
Mentor

@Anonymous 

I don't think I understand what you're asking for... I thought you were looking for a way to find a drawingview by a centerline. Could you describe your problem further? 🙂

0 Likes