2D intersect

2D intersect

NachoShaw
Advisor Advisor
433 Views
1 Reply
Message 1 of 2

2D intersect

NachoShaw
Advisor
Advisor

Hi

 

In a 3D sketch, you can intersect between a plane and a solid / surface to get the intersection profile on the plane.

 

Can we do the same in 2D? I'm not talking about the Project Cut feature because that will project ALL cut profile. lines for all bodies, I am looking for similar but I only need the projected profile of a selected plane and a selected body at the intersection.

 

If I simply project a selected body or face onto the 2D sketch, I get the whole profile instead of the intersecting profile.

 

FYI this is not a duplicated post, my other similar post is asking how to project a 3D sketch profile onto a 2D sketch 

 

 

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
434 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

I don't find an easy way to do so, but I created a VBA sample that can be a start for you to do it, you need to add more code in the sample in the TODO..., but there is a sample for how to do it for sketch lines, so you can easily add code for other types. The only special one is the spline type, I already added code for it so you can just use it:

 

Sub CreateIntersectionBetweenBodyAndPlanarSketch()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSk As PlanarSketch
    Set oSk = ThisApplication.CommandManager.Pick(kSketchObjectFilter, "Select a 2D sketch")
    
    Dim oBody As SurfaceBody
    Set oBody = ThisApplication.CommandManager.Pick(kPartBodyFilter, "Select a body")
    
    Dim oPlane As Plane
    Set oPlane = oSk.PlanarEntityGeometry
    
    Dim oIntersect As SurfaceBody
    Set oIntersect = ThisApplication.TransientBRep.CreateIntersectionWithPlane(oBody, oPlane)
    
    Dim oCurve As Edge
    For Each oCurve In oIntersect.Edges
        If oCurve.GeometryType = kLineSegmentCurve Then
            Dim oStart As Point2d
            Set oStart = oSk.ModelToSketchSpace(oCurve.StartVertex.Point)
            
            Dim oEnd As Point2d
            Set oEnd = oSk.ModelToSketchSpace(oCurve.StopVertex.Point)
            
            oSk.SketchLines.AddByTwoPoints oStart, oEnd
            
        ElseIf (oCurve.GeometryType = kCircleCurve) Then
            ' TODO...
            ' here you need to create the sketch circle...
            
        ElseIf (oCurve.GeometryType = kCircularArcCurve) Then
            ' TODO...
            ' here you need to create the sketch arc...
        
        ElseIf (oCurve.GeometryType = kEllipseFullCurve) Then
            ' TODO...
            ' here you need to create the sketch ellipse...
            
        ElseIf (oCurve.GeometryType = kEllipticalArcCurve) Then
            ' TODO...
            ' here you need to create the sketch elliptical arc...
            
        ElseIf (oCurve.GeometryType = kBSplineCurve) Then

            ' create sketch spline...
            
            Dim bSkInEdit As Boolean
            bSkInEdit = oDoc.ActivatedObject Is oSk
            
            If bSkInEdit Then
                oSk.ExitEdit
            End If
            
            Dim oBsplineCurve As BSplineCurve
            Set oBsplineCurve = oCurve.Geometry
            
            Dim oTempSk3d As Sketch3D
            Set oTempSk3d = oDoc.ComponentDefinition.Sketches3D.Add
            
            Dim oSkSpline3d As SketchFixedSpline3D
            Set oSkSpline3d = oTempSk3d.SketchFixedSplines3D.Add(oCurve.Geometry)
            
            Dim oPane As BrowserPane
            Set oPane = oDoc.BrowserPanes("Model")
            
            Dim oSkNode As BrowserNode
            Dim oTempSk3dNode As BrowserNode
            
            Set oSkNode = oPane.GetBrowserNodeFromObject(oSk)
            Set oTempSk3dNode = oPane.GetBrowserNodeFromObject(oTempSk3d)
            
            oPane.Reorder oSkNode, True, oTempSk3dNode
            
            Dim oProjectSpline As SketchEntity
            Set oProjectSpline = oSk.AddByProjectingEntity(oSkSpline3d)
            oProjectSpline.Reference = False
            
            oTempSk3d.Delete
            
            If bSkInEdit Then
                oSk.Edit
            End If
        End If
         
    Next
End Sub


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.

0 Likes