Dimension Outside

Dimension Outside

bradeneuropeArthur
Mentor Mentor
572 Views
5 Replies
Message 1 of 6

Dimension Outside

bradeneuropeArthur
Mentor
Mentor

How to move the dimension outside via coding?

And how to see if a dimension is moved outside via coding?

bradeneuropeArthur_0-1614448424392.png

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

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

JelteDeJong
Mentor
Mentor
Accepted solution

You can give this a go:

Sub Main()

    Dim doc As DrawingDocument = ThisDoc.Document
    Dim sheet As Sheet = doc.ActiveSheet
    Dim dimension As LinearGeneralDimension = 'sheet.DrawingDimensions.GeneralDimensions.Item(1)
        ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Pick a Linear dimansion")
    
Dim inside As Boolean = dimensionTextIsInside(dimension) MsgBox("Dimension text is inside = " & inside) placeTextOutside(dimension) End Sub Public Function dimensionTextIsInside(dimension As LinearGeneralDimension) As Boolean Dim textAboveLine As Double = 0.4 'Cm Dim lineSegment As LineSegment2d = dimension.DimensionLine Dim p1 As Point2d = lineSegment.StartPoint Dim p2 As Point2d = lineSegment.EndPoint Dim pText As Point2d = dimension.Text.Origin ' pythagoras at work but without taking the root as it is not needed here Dim lengthLineSegment As Double = (p2.X - p1.X) ^ 2 + (p2.Y - p1.Y) ^ 2 lengthLineSegment = lengthLineSegment + textAboveLine ^ 2 Dim p1ToText As Double = (pText.X - p1.X) ^ 2 + (pText.Y - p1.Y) ^ 2 Dim p2ToText As Double = (pText.X - p2.X) ^ 2 + (pText.Y - p2.Y) ^ 2 Return (p1ToText + p2ToText < lengthLineSegment) End Function Public Sub placeTextOutside(dimension As LinearGeneralDimension) Dim dinstanceOutside As Double = 1 ' Cm Dim textAboveLine As Double = 0.4 'Cm Dim lineSegment As LineSegment2d = dimension.DimensionLine Dim p1 As Point2d = lineSegment.StartPoint Dim p2 As Point2d = lineSegment.EndPoint Dim angle = Math.Atan((p2.X - p1.X) / (p2.Y - p1.Y)) Dim diffX As Double = dinstanceOutside * Math.Sin(angle) + textAboveLine * Math.Cos(angle) Dim diffY As Double = dinstanceOutside * Math.Cos(angle) + textAboveLine * Math.Sin(angle) Dim oTg = ThisApplication.TransientGeometry dimension.Text.Origin = oTg.CreatePoint2d(p2.X + diffX, p2.Y + diffY) If (dimensionTextIsInside(dimension)) Then dimension.Text.Origin = oTg.CreatePoint2d(p2.X - diffX, p2.Y - diffY) End If End Sub

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

Message 3 of 6

bradeneuropeArthur
Mentor
Mentor

Thanks @JelteDeJong 

That is really a nice and clever piece of code.

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor

Hi @JelteDeJong 

How would you prevent the dimension not is line with the dimension line?

Seems to have to do with where point 1 and point 2 is.
If it is a positive or a negative angle.

for example is it 90 degrees or -90 degrees or 270 degrees.

I will also have a look but maybe you have a quicker solution for it.

bradeneuropeArthur_0-1614512313553.png

Thanks in advance.

Regards,

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 6

JelteDeJong
Mentor
Mentor

I did have a look but i cant help you....

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

Message 6 of 6

bradeneuropeArthur
Mentor
Mentor

Thanks anyway 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes