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
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.
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)
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
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.
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
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.
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
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
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.
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
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.
can you provide model for test?
Can't find what you're looking for? Ask the community or share your knowledge.