Arange All Linear dimension

Arange All Linear dimension

vvvxxvvv333
Enthusiast Enthusiast
1,647 Views
16 Replies
Message 1 of 17

Arange All Linear dimension

vvvxxvvv333
Enthusiast
Enthusiast

Guys @Michael.Navara  @JelteDeJong  @MjDeck 

You know how to solve even impossible tasks. Can you find a solution for me?

When changing the parameters of a part, the dimensions in the drawing fly off.

Neteisingi.jpg

But I want to get the correct position.

Teisingi.jpg

Method ChainDimensionSet.Arrange( BaseDimension As LinearGeneralDimension )

It does not work for me or I do not know how to use it correctly, it centers the text but the size itself does not move to the right place. If you run a rule to count the number of linear dimensions, it turns out that the ChainDimensionSet is counted as separate dimensions. Maybe they can be collected in separate collections and then properly sorted by type. If you can't sort by designation here

Stilius.jpg

and position them by specifying the coordinates?

Does anyone solve this?

1,648 Views
16 Replies
Replies (16)
Message 2 of 17

Michael.Navara
Advisor
Advisor

Try this for first ChainDimensionSet

Dim drawing As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = drawing.ActiveSheet
Dim cds As ChainDimensionSet = sheet.DrawingDimensions.ChainDimensionSets(1)

cds.Arrange(cds.Members(1))

  

0 Likes
Message 3 of 17

vvvxxvvv333
Enthusiast
Enthusiast

Thanks for the reply Yes, your rule aligns text between callout lines.

Pozicijz.jpg

 But the dimension itself is not transferred to the correct position as specified in "E" and "D"

Stilius.jpg

 What would "Arange" do with a set of linear dimensions

 

0 Likes
Message 4 of 17

vvvxxvvv333
Enthusiast
Enthusiast

You can also center dimension text using this rule (without selecting a separate CainDimensionSet)

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

'  a reference to the active sheet
Dim oSheet As Sheet
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


But here is not to arrange dimension lines in a parametric distance depending on each other using standard methodsю if CainDimensionSet gets into the collection. He doesn't move and stays in the wrong position.

I need to get this result

E poz.jpg

Message 5 of 17

vvvxxvvv333
Enthusiast
Enthusiast

It seems impossible to get the desired result using standard Inventor tools. But it may be possible to read the existing coordinates of the dimension lines. And then calculate and assign the correct ones?

0 Likes
Message 6 of 17

vvvxxvvv333
Enthusiast
Enthusiast

and even so, these dimensions respond to the @JelteDeJong 

 rule.

        Dim doc As DrawingDocument = ThisApplication.ActiveDocument

        Dim oSheet As Sheet = doc.ActiveSheet

 

        Dim oview As DrawingView = osheet.DrawingViews(1)

        'Dim dimension As GeneralDimension

 

        Dim oTg = ThisApplication.TransientGeometry

 

        For Each dimension As DrawingDimension In oSheet.DrawingDimensions

 

            Dim midPointText As Point2d = dimension.Text.Origin

            Dim midPointView = oview.Center

            Dim textHeight = 0.5

 

            Dim newX As Double

            Dim newY As Double

 

            Dim deltaX As Double = (oview.Width * 0.5) + 0.6

            Dim deltaY As Double = (oview.Height * 0.5) + 0.6

 

            If (midPointText.X > midPointView.X + oview.Width / 2) Then

                newX = midPointView.X + deltaX

                newY = midPointView.Y

            End If

            If (midPointText.X < midPointView.X - oview.Width / 2) Then

                newX = midPointView.X - deltaX - textHeight

                newY = midPointView.Y

            End If

 

            If (midPointText.Y > midPointView.Y + oview.Height / 2) Then

                newX = midPointView.X

                newY = midPointView.Y + deltaY + textHeight

            End If

            If (midPointText.Y < midPointView.Y - oview.Height / 2) Then

                newX = midPointView.X

                newY = midPointView.Y - deltaY

            End If

 

            Dim newMidPoint As Point2d = oTg.CreatePoint2d(newX, newY)

 

            dimension.Text.Origin = newMidPoint

        Next

Can someone please fix this to give me the expected result?

0 Likes
Message 7 of 17

robertast
Collaborator
Collaborator

in 2021 Method ChainDimensionSet.Arrange was assigned [INVGEN-58548]. correct the error

0 Likes
Message 8 of 17

vvvxxvvv333
Enthusiast
Enthusiast

it's been three years and they haven't. Not sure if they will do it at all. That's why I'm looking for a roundabout way to solve this.

Well, I managed to move the dimensions, but they don't quite fit in the right place. I'm weak in programming, and those who are gurus don't want to help

 

Dim doc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = doc.ActiveSheet

Dim oFirstDim As DrawingDimension = Nothing
Dim oTg As TransientGeometry = ThisApplication.TransientGeometry
Dim oview As DrawingView = oSheet.DrawingViews(1)

' We find the first size and save its position
For Each dimension As DrawingDimension In oSheet.DrawingDimensions
    If TypeOf dimension Is LinearGeneralDimension Then
        oFirstDim = dimension
        Exit For
    End If
Next

If oFirstDim Is Nothing Then
    MessageBox.Show("No size found on the drawing")
    Exit Sub
End If

Dim oDimPoint As Point2d = oFirstDim.Text.Origin
Dim dDist As Double = 1.0 ' the specified distance between the sizes

' We arrange the rest of the dimensions at a given distance from the first one
For Each dimension As DrawingDimension In oSheet.DrawingDimensions
    If Not dimension Is oFirstDim AndAlso TypeOf dimension Is LinearGeneralDimension Then
        Dim oDimPointNew As Point2d = oTg.CreatePoint2d(oDimPoint.X + dDist, oDimPoint.Y)
        dimension.Text.Origin = oDimPointNew
        oDimPoint = oDimPointNew
		dimension.CenterText
    End If
Next

oSheet.Update()
0 Likes
Message 9 of 17

vvvxxvvv333
Enthusiast
Enthusiast

@Michael.Navara @WCrihfield  @bradeneuropeArthur @JelteDeJong

Can you take a look at what I've already created and correct the mistakes?
On the right side, the dimensions are already moving almost correctly.
Can you help modernize the code for the rest (left, right, top, and bottom)?

Dim doc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = doc.ActiveSheet
Dim oview As DrawingView = oSheet.DrawingViews(1)
Dim oTg = ThisApplication.TransientGeometry
Dim textHeight = 0.5   

Dim midPointView = oview.Center
Dim midPointText As Point2d
Dim newX As Double
Dim newY As Double
Dim deltaX As Double = (oview.Width * 0.5) + 0.6
Dim deltaY As Double = (oview.Height * 0.5) + 0.6
Dim counter As Integer = 0
Dim xValues As New List(Of Double)

For Each dimension As DrawingDimension In oSheet.DrawingDimensions
    midPointText = dimension.Text.Origin
    If midPointText.X > midPointView.X + oview.Width / 2 Then
        deltaX += counter * 0.6
        counter += 1
        If Not xValues.Contains(midPointText.X) Then
            xValues.Add(midPointText.X)
        End If
        newX = midPointView.X + deltaX
        newY = midPointText.Y
    Else
        newX = midPointText.X
        newY = midPointText.Y
    End If
    
    
    For i As Integer = 0 To xValues.Count - 1
        If Math.Round(midPointText.X, 2) = Math.Round(xValues(i), 2) Then
            deltaX = (oview.Width * 0.5) + 0.6 * i 
            newX = midPointView.X + deltaX
        End If
    Next
    
    dimension.Text.Origin = oTg.CreatePoint2d(newX, newY)
Next

 

0 Likes
Message 10 of 17

vvvxxvvv333
Enthusiast
Enthusiast

I will add files with a new rule

Maybe it is necessary to create a separate list of the distances at which the dimensions should be placed, and by comparing the position number with the existing dimensions, the required distance should be taken from that list?

Well, help me solve this problem, without your help I won't succeed

Message 11 of 17

robertast
Collaborator
Collaborator

@vvvxxvvv333  It seems that this can be solved

@JelteDeJong how about beer?
I promise a beer to the person who solves this problem

Message 12 of 17

jaimin.ja.3
Enthusiast
Enthusiast

Please go through the following link which provides a code for iLogic - Center & Arrange Dimensions - created by @ClintBrown3D. I have used this code before and it worked perfectly for me.

 

iLogic – Centre & Arrange Dimensions – Clint Brown

 

0 Likes
Message 13 of 17

vvvxxvvv333
Enthusiast
Enthusiast

it does not place the CainDimensionSet i at the correct distance from the drawing. It matches all other dimensions but not CainDimensionSet. I need to solve the problem if the set of dimensions also includes these dimensions so that they are all aligned equally.

Neteisingi -2.jpg

0 Likes
Message 14 of 17

vvvxxvvv333
Enthusiast
Enthusiast

I have this initial posture

Prdainis.jpg

 using any handling rules I can find I get this

Su taisykle.jpg

 But I had to get it this way

Turiu gauti.jpg

 

0 Likes
Message 15 of 17

romu51
Advocate
Advocate

Have a look at this:

https://clintbrown.co.uk/2020/07/11/ilogic-centre-arrange-dimensions/

  • it works well on randomly placed linear dimensions. 
  • it can get messy with the angular dimensions when overlapping linear ones. 
  • doesn't recentre the dimension when the rule had been previously applied and you want to update after you changed the model. 

I regularly use it to tidy things up. 

0 Likes
Message 16 of 17

vvvxxvvv333
Enthusiast
Enthusiast

What did I tell you above? This dimension of the circuit does not follow any rules that can be found on the Internet. It takes a lot of time to fix it

Watch the video if you don't believe it, after running the rules, the Chain dimensions remain in the wrong position

0 Likes
Message 17 of 17

vvvxxvvv333
Enthusiast
Enthusiast

I wrote this using "ChatGPT", it works almost fine. But I couldn't do it perfectly
I'm sure the programming gurus here could fix the AI bugs and solve this problem.

0 Likes