How to isolate profiles in 3D Sketches

How to isolate profiles in 3D Sketches

gerrardhickson
Collaborator Collaborator
291 Views
1 Reply
Message 1 of 2

How to isolate profiles in 3D Sketches

gerrardhickson
Collaborator
Collaborator

I'm trying to create multiple boundary patch features from a single 3D sketch that contains multiple non-planar profiles (imagine 2 or more sides of a cube).

 

The code below comes from the help file for "Loft feature with Non-Planar Section API Sample":

    ' Create a 3d profile to use as the section. Even though this section
    ' is closed the AddOpen method must be used because it is non-planar.
    Dim oProfile2 As Profile3D
    Set oProfile2 = oSketch3d.Profiles3D.AddOpen

 

Notice the line "oSketch3d.Profiles3D.AddOpen" - It seems that this line, and its counterpart, "AddClosed" create a Profile3D object containing ALL valid profiles. When I try to use this for my Boundary Patch feature, it fails if there is more than one profile, and I don't seem to be able to isolate a single profile to use for the Boundary Patch feature.

 

Furthermore, I tried adding a BoundaryPatchLoop using a collection of 3D Sketch Lines, and that also failed - all lines were defined such that their start and end points formed a one direction loop.

 

Here is a minimum code example to help explain the problem.

Private Function BoundaryPatchProblem()

Dim X1 As Integer
Dim oReg As New Collection
Dim oTG As TransientGeometry
Dim oSKLineCol1 As New Collection
Dim oSKLineCol2 As New Collection
Dim o3DSketch As Sketch3D
Dim oProf3D As Profile3D
Dim oSMCompDef As SheetMetalComponentDefinition
Dim oBPFeature As BoundaryPatchFeature
Dim oBPDef As BoundaryPatchDefinition

Set oSMCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Set oTG = ThisApplication.TransientGeometry
Set o3DSketch = oSMCompDef.Sketches3D.Add

'Create points for face 1
oReg.Add oTG.CreatePoint(0, 0, 0)
oReg.Add oTG.CreatePoint(0, 10, 0)
oReg.Add oTG.CreatePoint(10, 10, 0)
oReg.Add oTG.CreatePoint(10, 0, 0)
'Create points for face 2
oReg.Add oTG.CreatePoint(10, 10, 0)
oReg.Add oTG.CreatePoint(10, 10, 10)
oReg.Add oTG.CreatePoint(10, 0, 10)

'Line Collection for Profile 1
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oReg(1), oReg(2), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oReg(3), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oReg(4), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oSKLineCol1(1).StartSketchPoint, False)

'Line Collection for Profile 2
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oReg(4), oReg(5), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oReg(6), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oReg(7), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oSKLineCol2(1).StartSketchPoint, False)

'Create the profiles
Set oProf3D = o3DSketch.Profiles3D.AddClosed

'Create the boundary patch definition
Set oBPDef = oSMCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

'ATTEMPTING TO DEFINE THE BOUNDARY PATCH LOOPS WITH EITHER SKETCH LINE COLLECTION FAILS.
Call oBPDef.BoundaryPatchLoops.Add(oSKLineCol1)

'ATTEMPTING TO DEFINE THE BOUNDARY PATCH LINE WITH DEFINED PROFILES SUCCEEDS, BUT YOU CAN'T CHOOSE WHICH PROFILE TO USE.
Call oBPDef.BoundaryPatchLoops.Add(oProf3D)

'ATTEMPTING TO SELECT THE SECOND PROFILE FAILS SINCE THE PROFILE TYPE IS PROFILEPATH3D, NOT PROFILE3D.
Call oBPDef.BoundaryPatchLoops.Add(oProf3D(2))

'CREATING THE BOUNDARY PATCH FILES WITH THE PROFILES SINCE THERE ARE 2 NON-PLANAR PROFILES.
Set oBPFeature = oSMCompDef.Features.BoundaryPatchFeatures.Add(oBPDef)

End Function

 

How should I go about defining my boundary patches off a selected profile?

 

Thanks in advance.

0 Likes
Accepted solutions (1)
292 Views
1 Reply
Reply (1)
Message 2 of 2

gerrardhickson
Collaborator
Collaborator
Accepted solution

Resolved.

I had incorrectly defined oSkLineCol1 and oSkLineCol2 as Collections instead of ObjectCollections.

 

Here is the corrected code sample:

Private Function BoundaryPatchProblem()

Dim X1 As Integer
Dim oReg As New Collection
Dim oTG As TransientGeometry
Dim oSKLineCol1 As ObjectCollection
Dim oSKLineCol2 As ObjectCollection
Dim o3DSketch As Sketch3D
Dim oProf3D As Profile3D
Dim oSMCompDef As SheetMetalComponentDefinition
Dim oBPFeature As BoundaryPatchFeature
Dim oBPDef As BoundaryPatchDefinition

Set oSMCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Set oTG = ThisApplication.TransientGeometry
Set o3DSketch = oSMCompDef.Sketches3D.Add
Set oSKLineCol1 = ThisApplication.TransientObjects.CreateObjectCollection
Set oSKLineCol2 = ThisApplication.TransientObjects.CreateObjectCollection

'Create points for face 1
oReg.Add oTG.CreatePoint(0, 0, 0)
oReg.Add oTG.CreatePoint(0, 10, 0)
oReg.Add oTG.CreatePoint(10, 10, 0)
oReg.Add oTG.CreatePoint(10, 0, 0)
'Create points for face 2
oReg.Add oTG.CreatePoint(10, 10, 0)
oReg.Add oTG.CreatePoint(10, 10, 10)
oReg.Add oTG.CreatePoint(10, 0, 10)

'Line Collection for Profile 1
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oReg(1), oReg(2), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oReg(3), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oReg(4), False)
oSKLineCol1.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol1(oSKLineCol1.COUNT).EndSketchPoint, oSKLineCol1(1).StartSketchPoint, False)

'Line Collection for Profile 2
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oReg(4), oReg(5), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oReg(6), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oReg(7), False)
oSKLineCol2.Add o3DSketch.SketchLines3D.AddByTwoPoints(oSKLineCol2(oSKLineCol2.COUNT).EndSketchPoint, oSKLineCol2(1).StartSketchPoint, False)

'Create the profiles
Set oProf3D = o3DSketch.Profiles3D.AddClosed

'Create the boundary patch definition
Set oBPDef = oSMCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

'WITH UPDATED DECLARATIONS FOR oSKLineCol1 and oSKLineCol2, this line now works.
Call oBPDef.BoundaryPatchLoops.Add(oSKLineCol1)

'ATTEMPTING TO DEFINE THE BOUNDARY PATCH LINE WITH DEFINED PROFILES SUCCEEDS, BUT YOU CAN'T CHOOSE WHICH PROFILE TO USE.
'Call oBPDef.BoundaryPatchLoops.Add(oProf3D)

'ATTEMPTING TO SELECT THE SECOND PROFILE FAILS SINCE THE PROFILE TYPE IS PROFILEPATH3D, NOT PROFILE3D.
'Call oBPDef.BoundaryPatchLoops.Add(oProf3D(2))

'CREATING THE BOUNDARY PATCH FILES WITH THE PROFILES SINCE THERE ARE 2 NON-PLANAR PROFILES.
Set oBPFeature = oSMCompDef.Features.BoundaryPatchFeatures.Add(oBPDef)

End Function

 

0 Likes