Automate Intersection Drawing Dimension

Automate Intersection Drawing Dimension

frederic.vandenplas
Collaborator Collaborator
1,756 Views
12 Replies
Message 1 of 13

Automate Intersection Drawing Dimension

frederic.vandenplas
Collaborator
Collaborator

Hi,Knipsel.JPG

I'm looking for a way to automate the process of placing intersection dimensions.

There is no possibility to retrieve drawing dimension because there is no sketch dimension, it's a bend in sheetmetal.

One way that i'm thinking of is to create a sketch and get the intersection of 2 projected curves that are tangent connected to the arc. Can anyone help me out?

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Accepted solutions (1)
1,757 Views
12 Replies
Replies (12)
Message 2 of 13

chandra.shekar.g
Autodesk Support
Autodesk Support

@frederic.vandenplas ,

 

Please explain the requirement with more details (Video would be better). Supporting files will be better to test feasibility and make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 13

frederic.vandenplas
Collaborator
Collaborator

Hi @chandra.shekar.g  thank you for your feedback.

Actually it is very simple, i need the intersection on a drawing between two curves and place a dimension just like the build in functionallity, but for a couple of hundred flanges, it takes too much time.

All possible solutions and leads er welcome!

See the steps below

 

1.png

2.png

3.png

 

 

 

 

 

 

 

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 4 of 13

HermJan.Otterman
Advisor
Advisor

how do you create the part? with a sketch ? and then

are there honderets of flanges on one  part?

how would / can you select the lines?

can you send the part? is this automated? how?

using sketches or workpoints in some order might work?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 13

frederic.vandenplas
Collaborator
Collaborator

@HermJan.Otterman 

We have 1 sheetmetal template part, which could all have theoretically 8 bends which can flip back or forward.

So if we have 100 plates to cover the wall...

We use a template drawing to generate the drawings, but we never managed to keep the dimensions.

The parts are relatively complex to maintain adaptive and ilogic driven, so we tried already everything to get somewhat of a reference to the intersection in our parts.

The drawings need to be inspected anyway, so the idea was to select the 3 lines and execute the code...

So i don't think we'll ever modify the parts, because they do now what they need to do...

 

 

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 6 of 13

HermJan.Otterman
Advisor
Advisor

I think selecting the lines that you want to dimension (in the right order) is the main problem..?

if jou have a template, does that have a part or sketches?

id the part is (over)complete in the template, you could give the lines you want to dimesion attributes (only with code) and then use those to select them for dimensioning.

maybe you could share your template?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 7 of 13

YuhanZhang
Autodesk
Autodesk
Accepted solution

Here is a VBA sample for you to try. Open your drawing, and run the VBA macro, then select two linear curves to get their intersection point, then select another linear curve to dimension it from the intersection point:

 

Sub DimIntersectionPoint()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oCurve1 As DrawingCurveSegment
    Dim oCurve2 As DrawingCurveSegment
    
    MsgBox "Select two linear curves to get their intersection point"
    
    Set oCurve1 = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select first drawing curve for intersection point")
    Set oCurve2 = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select second drawing curve for intersection point")
    
    MsgBox "Select another linear curve to add dim from intersection point"
    Dim oCurve3 As DrawingCurveSegment
    Set oCurve3 = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select another drawing curve to add dimension from intersection point")
    
    Dim oDrawingView As DrawingView
    Set oDrawingView = oCurve1.Parent.Parent
    
    Dim oViewSk As DrawingSketch, oIntersectionSk As DrawingSketch
    If oDrawingView.Sketches.Count > 0 Then
        
        For Each oViewSk In oDrawingView.Sketches
            If oViewSk.AttributeSets.NameIsUsed("IntersectionPointSketch") Then
                Set oIntersectionSk = oViewSk
                Exit For
            End If
        Next
    End If
    
    If oIntersectionSk Is Nothing Then
        Set oIntersectionSk = oDrawingView.Sketches.Add
        oIntersectionSk.AttributeSets.Add "IntersectionPointSketch", True
    End If
     
     oIntersectionSk.Edit
        Dim oPt As SketchPoint
        Set oPt = oIntersectionSk.SketchPoints.Add(ThisApplication.TransientGeometry.CreatePoint2d(2, 2), True)
        
        Dim oProjectedCurve1 As SketchLine, oProjectedCurve2 As SketchLine
        Dim oProjectedEntity As SketchEntity
        Set oProjectedEntity = oIntersectionSk.AddByProjectingEntity(oCurve1.Parent)
        Set oProjectedCurve1 = oProjectedEntity
        
        Set oProjectedEntity = oIntersectionSk.AddByProjectingEntity(oCurve2.Parent)
        Set oProjectedCurve2 = oProjectedEntity
        
        Call oIntersectionSk.GeometricConstraints.AddCoincident(oPt, oProjectedCurve1)
        Call oIntersectionSk.GeometricConstraints.AddCoincident(oPt, oProjectedCurve2)
        
         Dim oProjectedCurve3 As SketchLine
        Set oProjectedEntity = oIntersectionSk.AddByProjectingEntity(oCurve3.Parent)
        Set oProjectedCurve3 = oProjectedEntity
        
        Dim oDimConstraint As DimensionConstraint
        Set oDimConstraint = oIntersectionSk.DimensionConstraints.AddOffset(oProjectedCurve3, oPt, oPt.Geometry, False, True)
     oIntersectionSk.ExitEdit
     
     Dim oSheet As Sheet
     Set oSheet = oDrawingView.Parent
     
     Dim oCol As ObjectCollection
     Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
     oCol.Add oDimConstraint
     Call oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oIntersectionSk, oCol)
End Sub

You can add the macro to UI as a ribbon button from Customize dialog if you like. Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 8 of 13

frederic.vandenplas
Collaborator
Collaborator

@YuhanZhang 

Waaw, i'm speechless! This is exactly how i wanted it and it's even better then the "through user interface" way!

The dimension is also linked to the geometry as one would expect! Thumbs up 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 9 of 13

HermJan.Otterman
Advisor
Advisor

I altered your code a bit, so it works as through the Inteface,

(iLogic)

    Sub main
        Dim oDoc As DrawingDocument
        oDoc =  ThisDoc.Document

        Dim oCurve1 As DrawingCurveSegment
        Dim oCurve2 As DrawingCurveSegment

        MsgBox("Select two linear curves to get their intersection point")

        oCurve1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select first drawing curve for intersection point")
        oCurve2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select second drawing curve for intersection point")

        Dim oSheet As Sheet
        oSheet = oCurve1.Parent.Parent.Parent

        'Sheet.CreateGeometryIntent(Geometry As Object, [Intent] As Variant ) As GeometryIntent 
        Dim firstGI As GeometryIntent = oSheet.CreateGeometryIntent(oCurve1.Parent, oCurve2.Parent)

        MsgBox("Select two other linear curves to add dim from intersection point")
        Dim oCurve3 As DrawingCurveSegment
        Dim oCurve4 As DrawingCurveSegment
        oCurve3 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select another drawing curve to add dimension from intersection point")
        oCurve4 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select another drawing curve to add dimension from intersection point")

        Dim SecondGI As GeometryIntent = oSheet.CreateGeometryIntent(oCurve3.Parent, oCurve4.Parent)

        Dim oDrawingView As DrawingView
        oDrawingView = oCurve1.Parent.Parent

        Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
        Dim TextPoint As Point2d = oTG.CreatePoint2d(2, 2)

        oSheet.DrawingDimensions.GeneralDimensions.AddLinear(TextPoint, firstGI, SecondGI, DimensionTypeEnum.kAlignedDimensionType)

    End Sub

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 10 of 13

frederic.vandenplas
Collaborator
Collaborator

 

@HermJan.Otterman Thank you for your effort but the solution from @YuhanZhang is actually nicer (for me) because the intersection lines are not showing up and thus not spoiling the views anymore.

So that solution unexpectedly solverd 2 "problems"


Knipsel.JPG

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 11 of 13

HermJan.Otterman
Advisor
Advisor

Hello Frederic, I tried the solition of @YuhanZhang, but with me the dimension was within brackets, and I wanted the extension lines, so for my self I wanted a different solution and when I found it I wanted it to share with you all. so now there are two solutions and everyone can choose what fits them best.

thanks for asking the question! the answer of @YuhanZhang, save me a lot of time, to find the other solution.

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 12 of 13

m_reza_shahparast
Contributor
Contributor

Hi dear @HermJan.Otterman,

@WCrihfield @YuhanZhang 

 

Thank you for your help.

Do you know how I can use this code in VB.NET?

I have 4 "DrawingCurve" objects in my code, but ".AddLinear" doesn’t work.

 

0 Likes
Message 13 of 13

HermJan.Otterman
Advisor
Advisor

in VB.net the code will be almost the same, you need to have a refrence to Inventor (for example : invApp), and than replace the "thisapplications" and for line 3, the oDoc = invApp.ActiveDocument  . the rest of the code will be the same.  when looking at the first picture, start the code, it will ask for the the first two lines, select the top one and the left one, then it wil ask of the second two lines, select the left and thbottom one. that the dimension should be placed. 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes