Drawing : automated diameter dimensions

Drawing : automated diameter dimensions

patrice.vallet
Contributor Contributor
1,836 Views
5 Replies
Message 1 of 6

Drawing : automated diameter dimensions

patrice.vallet
Contributor
Contributor

I'm working to automate a drawing.

I have found on the forum how to add dimension between 2 workpoints and 2 face and I have automated some of my dimension using attribute on face and workpoint of my model.

 

Now I'm struggling to add a dimension diameter. 

I would like to add this kind of dimension by ilogic but I didn't find something.

Is it possible ? If yes how can I do that ? If not, are there an other way to indicate the diameter ?

image.png

 

0 Likes
Accepted solutions (1)
1,837 Views
5 Replies
Replies (5)
Message 2 of 6

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @patrice.vallet 

Try this 🙂

Dim oSheet As Sheet = ActiveSheet.Sheet
For Each oView As DrawingView In oSheet.DrawingViews
	For Each oCurve As DrawingCurve In oView.DrawingCurves
		If oCurve.CurveType = CurveTypeEnum.kCircleCurve
		Dim oIntent As GeometryIntent = oSheet.CreateGeometryIntent(oCurve, PointIntentEnum.kCircularLeftPointIntent)
		Dim oPoint As Point2d = oIntent.PointOnSheet.Copy
		Dim oVector As Vector2d = oCurve.CenterPoint.VectorTo(oPoint)
		oVector.ScaleBy(.3)
		oVector.AddVector(ThisApplication.TransientGeometry.CreateVector2d(oVector.X, Abs(oVector.X)))
		oPoint.TranslateBy(oVector)
	oSheet.DrawingDimensions.GeneralDimensions.AddDiameter(oPoint, oIntent, False)
End If
Next
Next

It'll add diameter dimension to ALL circles on the sheet. But you can modify it to only add the dimensions to the circles you want, now that you have the example code 🙂

Message 3 of 6

patrice.vallet
Contributor
Contributor

Hi  @JhoelForshav ,

Thanks for the solution this works as I need.

 

I have just a question about the position of the dimension. You use vector, but it's the first time I see that.

 

Dim oPoint As Point2d = oIntent.PointOnSheet.Copy
Dim oVector As Vector2d = aoDrawCurves3.CenterPoint.VectorTo(oPoint)
oVector.ScaleBy(.3)
oVector.AddVector(ThisApplication.TransientGeometry.CreateVector2d(oVector.X, Abs(oVector.X)))
oPoint.TranslateBy(oVector)

 

I would like to choose the position so, could you explain me how vectors work ? and how can I use it to choose the position ?

0 Likes
Message 4 of 6

JhoelForshav
Mentor
Mentor

Hi @patrice.vallet 

I'm glad that it worked as expected. I just used a vector to translate a point in this case. The function to place the diameter dimension still takes a point as an argument.

A vector has a magnitude (length) and a direction. What the code does is that it first gets the vector representing the relative difference in position between the point of our geometry intent (the point that our arrow for the dimension will attach to) and the centerpoint of the circle. this gives us a direction straight to the left in this case and a magnitude being the radius of the circle. I then scale the vector by a factor of 0.3 , dubble the length in X direction and add the previous x-value of the direction to the y value of the vector. It's all just operations to get the point to where I think it wood look good. Then I take a copy of our intent point and translates it by this vector, giving me a point at a good relative position to the intent point in my opinion. That is the point I then use as position for the dimension text.

I hope this made some sense to you 😄

Message 5 of 6

patrice.vallet
Contributor
Contributor

Hi @JhoelForshav 

Thanks for the explanation. I have to try by myself to change value to understand perfectly the vector.

 

For the moment I have used the following code to place my dimension (something I am used with)

Dim oPt1 As Point2d
oPt1 = oTG.CreatePoint2d(oView.Left +oView.Width- 1,oView.Top+1)

Dim oID As GeneralDimension
oID = oGeneralDims.AddDiameter(oPt1, oIntent, False)

So I have this result :

image.png

And what I want :

image.png

 As you can see the code pick the bottom left point.

Do you know how can I position the picking point ?

0 Likes
Message 6 of 6

JhoelForshav
Mentor
Mentor

@patrice.vallet 

This has to do with the LeaderFromCenter-property in GeneralDimensions.AddDiameter.

Try your last line like this 🙂

 

oID = oGeneralDims.AddDiameter(oPt1, oIntent, False, False, True)

 

0 Likes