Dimension centering, Arrows Inside, Skip small dimension

Dimension centering, Arrows Inside, Skip small dimension

Anonymous
Not applicable
2,335 Views
14 Replies
Message 1 of 15

Dimension centering, Arrows Inside, Skip small dimension

Anonymous
Not applicable

When I use the Center Dimension Text API Sample (from Inventor help), all linear dimensions are centered.

I would like to skip all dimensions that are too small and have their arrowheads outside.

Unfortunately - although I can see the arrowheads outside in my drawing, the DrawingDimension.ArrowheadsInside property is true - so I cannot distinguish between dimensions using this property.

 

Other method that I tried is to check the minimal dimension value that makes the arrowheads inside. It's 6mm (don't ake me why) but only for scale 1:1 and will change according to scale of a view.

Unfortunately - I can get the value of dimension and I can get the scale of a view, but I don't see how to connect them. It seems that both dimensions and views are parts of sheet, but I cannot see how to check, on which view is specific dimension.

 

Changing dimension style in not an option.

 

Maybe You have an another solution?

 

0 Likes
Accepted solutions (2)
2,336 Views
14 Replies
Replies (14)
Message 2 of 15

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

If you measure the dimensionline it'll always be in cm units on the drawing sheet. So the scale doesn't matter in that case.

Try this and see if it works for you 🙂

Public Sub CenterAllDimensions()
    ' Set a reference to the active drawing document
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Set a reference to the active sheet
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet

    Dim oDrawingDim As DrawingDimension

    ' Iterate over all dimensions in the drawing and
    ' center them if they are linear or angular.

    For Each oDrawingDim In oSheet.DrawingDimensions
        If TypeOf oDrawingDim Is LinearGeneralDimension Or _
           TypeOf oDrawingDim Is AngularGeneralDimension Then
           
           Dim oLength As Double
            Call oDrawingDim.DimensionLine.Evaluator.GetLengthAtParam(0, 1, oLength)
            If oLength > 0.6 Then Call oDrawingDim.CenterText
           
        End If
    Next
End Sub
Message 3 of 15

Anonymous
Not applicable

005.png

As You can see scale of a view matters.

Your solution would work only if multiplied by scale of a view

0 Likes
Message 4 of 15

JhoelForshav
Mentor
Mentor

@tomasz.dabrowskiUGC2B 

The dimensionline is not part of the drawing view so it's not affected by the drawing view scale. Its dimension is the length of it on the drawing sheet.

 

Message 5 of 15

Anonymous
Not applicable

It's strange, but on my computer it doesn't work.

I put screens before and after running macro

 

 
0 Likes
Message 6 of 15

robertast
Collaborator
Collaborator

Surprisingly, for me, this rule works both as a macro and as an iLogic. And works great. Thanks @JhoelForshav 

0 Likes
Message 7 of 15

robertast
Collaborator
Collaborator

Here's a video of how it works for me

Message 8 of 15

JhoelForshav
Mentor
Mentor

@Anonymous 

It's very strange... See if it works better to get the paramextents first and not just use 0 & 1. I doubt it'll make a difference but still.

Public Sub CenterAllDimensions()
    ' Set a reference to the active drawing document
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Set a reference to the active sheet
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet

    Dim oDrawingDim As DrawingDimension

    ' Iterate over all dimensions in the drawing and
    ' center them if they are linear or angular.

    For Each oDrawingDim In oSheet.DrawingDimensions
        If TypeOf oDrawingDim Is LinearGeneralDimension Or _
           TypeOf oDrawingDim Is AngularGeneralDimension Then
           Dim minParam As Double
           Dim maxParam As Double
           Dim oLength As Double
           Call oDrawingDim.DimensionLine.Evaluator.GetParamExtents(minParam, maxParam)
            Call oDrawingDim.DimensionLine.Evaluator.GetLengthAtParam(minParam, maxParam, oLength)
            If oLength > 0.6 Then
            Call oDrawingDim.CenterText
            End If
        End If
    Next
End Sub

 Also, try running this iLogic rule and pick the dimension that shouldn't be updated to see what length value it will return:

Dim oDim As LinearGeneralDimension = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Pick the dimension")
Dim oLength As Double
Dim minParam, maxParam As Double

oDim.DimensionLine.Evaluator.GetParamExtents(minParam, maxParam)
oDim.DimensionLine.Evaluator.GetLengthAtParam(minParam, maxParam, oLength)
MsgBox(oLength)
Message 9 of 15

Anonymous
Not applicable

I'll try Your advices later, but for now I added one line of code, which will show length of every dimension line.

I put it right before cenetring command:

MsgBox ("Dimension " & oDrawingDim.Text.Text & " has Dimension Line " & oLength)

Result is in the attachment

 

You can see that with different scales, length of dimension line is the same

0 Likes
Message 10 of 15

JhoelForshav
Mentor
Mentor

This is really interesting... Could you attach the ipt and dwg so I can investigate? 🙂

0 Likes
Message 11 of 15

Anonymous
Not applicable

Geting the paramextents didn't help - the same resut.

Picking method doesn't work on my computer - rule works, but I'am unable to click on dimension.

 

But I can get the dimesionline length manualy.

On my drawing now I have only 2 dimensions - both show 3(mm) but are on different scales.

008.png

Here is what I see in locals window:

009.png

Now I can calculate the difference between X, Y and Z for MinPoint and MaxPoint.

For X is 0, for Z is almost 0 (should be 0 but doesn't matter) and for Y in both cases is 0,3

 

I attach both ipt and dwg files as requested

0 Likes
Message 12 of 15

robertast
Collaborator
Collaborator

You have something wrong with the details. I refined your details in the drawing, added new ones and added dimensions. Everything seems to work ...

Only with me version 2021

Message 13 of 15

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

I see what it is now... You have set your general dimension type of the drawing views to true. This means the dimension is actually based on the 3D-model geometry and not the lines on the drawing. So the dimensionline is not a LineSegment2d but a LineSegment (3d) and it comes from the model itself...

 

This setting is for isometric views so you can set a dimension that represents the actual length in the model rather lengths based on the drawing curves... When placing a non-isometric view this setting should be false per default. Have you overridden it?

 

Try this:

1. Delete the dimensions

2. Right click the view > General Dimension Type > Projected

3. Place the dimensions again

4. Run the script.

 

That should do it 🙂

Message 14 of 15

Anonymous
Not applicable

Bingo.

Changing General Dimension Type from True to Projected solves my problem.

I also had to change the value >0.6 to >=0.48 (I found this value experimentally), but don't really know why.

I just wonder why I had this "true" dimension type. In other drawings I have this set to "projected".

Case solved - Thank You very much

Message 15 of 15

robertast
Collaborator
Collaborator

For dimensions to behave correctly in drawings, please vote in the topic

https://forums.autodesk.com/t5/inventor-ideas/arrange-dimension/idi-p/10776235