Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

3d sketch intersect to selected plane

7 REPLIES 7
Reply
Message 1 of 8
NachitoMax
601 Views, 7 Replies

3d sketch intersect to selected plane

Hey

 

Anyone able to help? I'm trying to set up a method that will add a 3d sketch and intersect it between a selected plane and a selected body. The result should be a 2d sketch profile on the selected plane where it intersected with the body.

 

Any ideas?

 

 

 

Nacho

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.


7 REPLIES 7
Message 2 of 8
dgreatice
in reply to: NachitoMax

Hi,

 

try this (VBA):

 

Public Sub CreateIntersectionCurveSelectedPlane()
Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oCP As WorkPlane
Dim o3DSkt As Sketch3D
Dim oSurfBody As SurfaceBody
Dim oFaceCol As FaceCollection
Dim oFace As Face

 

Set oApp = ThisApplication
Set oPD = oApp.ActiveDocument
Set oPCD = oPD.ComponentDefinition
Set oCP = oApp.CommandManager.Pick(kWorkPlaneFilter, "Select Plane")
Set o3DSkt = oPCD.Sketches3D.Add
Set oSurfBody = oPCD.SurfaceBodies(1)
Set oFaceCol = oApp.TransientObjects.CreateFaceCollection

 

For Each oFace In oSurfBody.Faces
Call oFaceCol.Add(oFace)
Next

 

Call o3DSkt.IntersectionCurves.Add(oCP, oFaceCol)
End Sub

 

iLogic version:

 

Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oCP As WorkPlane
Dim o3DSkt As Sketch3D
Dim oSurfBody As SurfaceBody
Dim oFaceCol As FaceCollection
Dim oFace As Face

 

oApp = ThisApplication
oPD = oApp.ActiveDocument
oPCD = oPD.ComponentDefinition
oCP = oApp.CommandManager.Pick(selectionfilterenum.kWorkPlaneFilter, "Select Plane")
o3DSkt = oPCD.Sketches3D.Add
oSurfBody = oPCD.SurfaceBodies(1)
oFaceCol = oApp.TransientObjects.CreateFaceCollection

 

For Each oFace In oSurfBody.Faces
Call oFaceCol.Add(oFace)
Next

 

3DSkt.IntersectionCurves.Add(oCP, oFaceCol)

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 3 of 8
NachitoMax
in reply to: dgreatice

Hi

 

Thanks for the code, its getting me part way there 🙂

 

Im struggling on the next part. I am projecting the intersection onto a 3D sketch on the plane. I am then adding a 2D sketch on the same plane and i need to project the 3D geometry onto the 2D sketch. How can i do that? I cant seem to find the right sketch entity

 

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.


Message 4 of 8
NachitoMax
in reply to: NachitoMax

So I was able to loop through the 3D sketch entities and project them to the 2D sketch but I ended up getting an error when I tried to extrude the profile. The extrude profile would highlight but not extrude.....

 

I have looked at SketchEntity3D which does project but I think I need some sort of profile....

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.


Message 5 of 8
dgreatice
in reply to: NachitoMax

Before you do this, please check are all closed profile at 2D sketch?

 

VBA Version (Update) :

 

Public Sub CreateIntersectionCurveSelectedPlane()
Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oCP As WorkPlane
Dim o3DSkt As Sketch3D
Dim oSurfBody As SurfaceBody
Dim oFaceCol As FaceCollection
Dim oFace As Face
Dim o2DSkt As PlanarSketch
Dim o3DSktEntEnum As SketchEntity3D
Dim o2DProfile As Profile
Dim oExtDef As ExtrudeDefinition
Dim oExtFeat As ExtrudeFeature

Set oApp = ThisApplication
Set oPD = oApp.ActiveDocument
Set oPCD = oPD.ComponentDefinition
Set oCP = oApp.CommandManager.Pick(kWorkPlaneFilter, "Select Plane")
Set o3DSkt = oPCD.Sketches3D.Add
o3DSkt.Name = "3D Sketch" & oPCD.Sketches3D.Count
Set oSurfBody = oPCD.SurfaceBodies(1)
Set oFaceCol = oApp.TransientObjects.CreateFaceCollection

For Each oFace In oSurfBody.Faces
Call oFaceCol.Add(oFace)
Next

Call o3DSkt.IntersectionCurves.Add(oCP, oFaceCol)
Set o2DSkt = oPCD.Sketches.Add(oCP, False)
o2DSkt.Name = "Sketch" & oPCD.Sketches.Count

For Each o3DSktEntEnum In o3DSkt.SketchEntities3D
If o3DSktEntEnum.Type = kSketchLine3DObject Then
Call o2DSkt.AddByProjectingEntity(o3DSktEntEnum)
End If
Next
o3DSkt.Visible = False
Set o2DProfile = o2DSkt.Profiles.AddForSolid
Set oExtDef = oPCD.Features.ExtrudeFeatures.CreateExtrudeDefinition(o2DProfile, kNewBodyOperation)
Call oExtDef.SetDistanceExtent(1, kPositiveExtentDirection)
Set oExtFeat = oPCD.Features.ExtrudeFeatures.Add(oExtDef)

End Sub

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 6 of 8
NachitoMax
in reply to: dgreatice

Hi

Thanks for the reply. I had actually generated the same code as yours with the only difference being the naming of the sketches. When i run your code, i get an error

 

Invalid procedure call or argument 

on this code line - Set o2DProfile = o2DSkt.Profiles.AddForSolid

 

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.


Message 7 of 8
NachitoMax
in reply to: dgreatice

Hi

 

in further testing, the type of 3D sketch entity check was incorrect as it was looking for a line. I can only test for sketch entity, not a specific entity like a line or spline as the object shapes vary.

 

both yours and my code fail at the same place. I can get the 2D profile into the 2D sketch and when i got to manually extrude, the profile highlights but will not extrude.

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.


Message 8 of 8
dgreatice
in reply to: NachitoMax

can you provide model for test?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report