Moving a dimension to a position outside the arrow with ilogic

Moving a dimension to a position outside the arrow with ilogic

heliston_guimaraes
Participant Participant
575 Views
5 Replies
Message 1 of 6

Moving a dimension to a position outside the arrow with ilogic

heliston_guimaraes
Participant
Participant

Hello everyone,
I created a dimension with ilogic. However, the dimension always appears centered, regardless of whether the arrows are inwards or outwards. How do I move a dimension to a position outside the arrow with ilogic?
I attach two images: one with the dimension centered and how the program creates it and the other with the dimension as I would like it to be created.

Thank you to anyone who can take the time to help.

 

 

 

Dim cotaCcomprimento_SF = genDims_SF.AddLinear("cotaCcomprimento_SF", VIEW01_SF.SheetPoint(DistCotaComprY + .1, + DistCotaComprX), diam1_SF, profcsliso_SF, DimensionTypeEnum.kVerticalDimensionType,) 
cotaCcomprimento_SF.NativeEntity.TolerancePrecision = 2
cotaCcomprimento_SF.NativeEntity.Tolerance.SetToDeviation(+0.00, -0.03 * .1)

 

heliston_guimaraes_0-1696259182076.png 

heliston_guimaraes_1-1696259202759.png

 

 

0 Likes
Accepted solutions (2)
576 Views
5 Replies
Replies (5)
Message 2 of 6

Michael.Navara
Advisor
Advisor

You can use something like this 

Dim drwDim As Inventor.LinearGeneralDimension = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Pick dim")

Dim txtOrigin = drwDim.Text.Origin
txtOrigin.TranslateBy(drwDim.DimensionLine.Direction.AsVector())
drwDim.Text.Origin = txtOrigin
Message 3 of 6

heliston_guimaraes
Participant
Participant

Thanks for the answer. It works, but it's not exactly what I need, as it will always require me to do manual editing, and if there are several quotas with the same problem, I will always need to check them one by one.
But I will save the code as it may be useful to me.
Thanks!

0 Likes
Message 4 of 6

Michael.Navara
Advisor
Advisor
Accepted solution

If you want more complex code to fix drawing, see this post.

It solves little bit different task, but you can combine it together.

 

Message 5 of 6

m_baczewski
Advocate
Advocate
Accepted solution

Hi @heliston_guimaraes 

To start, you need to:

  1. Define the document.
  2. Find the dimension through the API and define it.
  3. Define the initial position of the dimension of interest.
  4. Define the new position of the dimension as a Point2D; in your case, you will need to add a value to the Y-coordinate.
  5. Assign the new position to the dimension.
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

Dim oDimensions As drawingDimensions
oDimensions = oDoc.ActiveSheet.DrawingDimensions

Dim oDimension1 As LinearGeneralDimension
oDimension1 = oDimensions.Item(19)

Dim poczatkowePolozenieWymiaru1 As Point2d	
poczatkowePolozenieWymiaru1 = oDimension1.Text.Origin

Dim nowePolozenieWymiaru1 As Point2d	
nowePolozenieWymiaru1 = oTG.CreatePoint2d(poczatkowePolozenieWymiaru1.X - 1, poczatkowePolozenieWymiaru1.Y - 0.35)

oDimension1.Text.Origin = nowePolozenieWymiaru1

This is the method I've come up with, but there may be a better and faster way to solve this problem.

Message 6 of 6

heliston_guimaraes
Participant
Participant

Thank you all. The comments were very useful and I was able to extract information to get the final result I wanted.
Below I leave the final code in which I obtained the result.
The last line of the schedule is what I needed.

Thanks

 

Dim cotaCcomprimento_SF = genDims_SF.AddLinear("cotaCcomprimento_SF", VIEW01_SF.SheetPoint(DistCotaComprY + .1, + DistCotaComprX), diam1_SF, profcsliso_SF, DimensionTypeEnum.kVerticalDimensionType,) 
cotaCcomprimento_SF.NativeEntity.TolerancePrecision = 2
cotaCcomprimento_SF.NativeEntity.Tolerance.SetToDeviation(+ 0.00, -0.03 * .1)
cotaCcomprimento_SF.NativeEntity.Text.Origin = ThisApplication.TransientGeometry.CreatePoint2d(cotaCcomprimento_SF.NativeEntity.Text.Origin.X, cotaCcomprimento_SF.NativeEntity.Text.Origin.Y+1)