Aligning 2 dimensions

Aligning 2 dimensions

Anonymous
Not applicable
674 Views
3 Replies
Message 1 of 4

Aligning 2 dimensions

Anonymous
Not applicable

Hi all,

How can I fix 2 different dimensions to align each other? When I run my drawing automation application, these 2 dimensions dancing apart which must be stick together. It is very easy to adjust the position when I create a drawing one by one manually but I don't know how to solve this problem when I cannot do it manually while running a program. Thanks in advance for your help!

 

Untitled-5.pngUntitled-6.png

0 Likes
Accepted solutions (2)
675 Views
3 Replies
Replies (3)
Message 2 of 4

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

I assume you can retrieve the objects (LinearGeneralDimension) of these two dimensons in your drawing automation code?

 

Then it's just q question of aligning the text origins for the dimensions - In this case give them the same Y-value.

Here's an example:

 

dim1.PNG

 

Dim oSheet As Sheet = ActiveSheet.Sheet
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oDim1 As LinearGeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.Item(1)
Dim oDim2 As LinearGeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.Item(2)

Dim pt1 As Point2d = oDim1.Text.Origin
Dim pt2 As Point2d = oDim2.Text.Origin
Dim pt3 As Point2d = oTG.CreatePoint2d(pt2.X, pt1.Y)
oDim2.Text.Origin = pt3

 

 dim2.PNG

0 Likes
Message 3 of 4

Anonymous
Not applicable

@JhoelForshav Thank you for your constant help! 

 

Yes, this whole view is quoted by "Retrieve Model Annotations".

 

In your code, seems like that it assumed that there are only 2 dimensions. What if I have multiple dimensions in the drawing? How can I select out the only 2 dimensions that I want to fix together? 

Dim oDim1 As LinearGeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.Item(1)
Dim oDim2 As LinearGeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.Item(2)

 

0 Likes
Message 4 of 4

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

As I said I thought that you already had a way to get the dimensions objects. But now I understand.

Since the dimensions are retrieved, we could use the parameter name of the dimension in the model to get them.

 

In this example the parameter names in the model for the two retrieved dimensions are d6 and d7.

Hope it helps 🙂

 

Dim oSheet As Sheet = ActiveSheet.Sheet
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oDim1 As LinearGeneralDimension
Dim oDim2 As LinearGeneralDimension
For Each oDim As GeneralDimension In oSheet.DrawingDimensions.GeneralDimensions
	If oDim.Retrieved
		If oDim.RetrievedFrom.Parameter.Name = "d6" Then oDim1 = oDim
		If oDim.RetrievedFrom.Parameter.Name = "d7" Then oDim2 = oDim
	End If
	If oDim1 IsNot Nothing AndAlso oDim2 IsNot Nothing Then Exit For
Next

Dim pt1 As Point2d = oDim1.Text.Origin
Dim pt2 As Point2d = oDim2.Text.Origin
Dim pt3 As Point2d = oTG.CreatePoint2d(pt2.X, pt1.Y)
oDim2.Text.Origin = pt3