I'm having difficulties with using IModelDocExtension::SketchOffsetOnSurface. The macro that I'm working on (VBA) is using PMP's to store user selections for (1) Face and (3) Edges. I'm currently using the PMP to:
- Get Face from PMP SelectionBox.
- Create Offset Surface from said Face.
- Isolate Surface.
- Get Edges (qty: 3) from PMP SelectionBoxes (qty: 3) from isolated surface.
- Get pointer and execute SketchOffsetOnSurface/GeodesicSketchOffset Method.
- After Offset on Surface has completed, get the sketch segments. (CAN'T select segments).
- Trim corners (can't do this until I manage to get the segments created).
The depiction above shows post-trim, but shows the edges offset, like I'm working with.
So - I am able to recall & select the required Edges on the offset surface - no issues there now. I'm only able to successfully offset all of the edges about, say, half of the time. All of the surfaces I'm testing have four outer edges, roughly perpendicular, and have minimal curvature to them. I don't this this is a geometric condition issue - as I can successfully complete the offset condition manually.
I get my edges from persistent reference ID's as shown:
Dim myEnt1 As Entity
Dim swEdge1 As SldWorks.Edge
Set swEdge1 = swModelDocExt.GetObjectByPersistReference3(Edge1_ID, longstatus)
Set myEnt1 = swEdge1
myEnt1.Select4 True, Nothing
Then I use the sketch offset on surface method. The way that I want to accomplish this is to select the Edges individually, as they each require their own offset distance (EdgeDist1). This is retrieved by a NumberBoxes in the PMP. Given that, I should only be dealing with a single 3D Sketch, created by the first SketchOffsetOnSurface method. This sequence, most of the time, works on all three Edges, and sometimes only works on two of the Edges. I can't distinguish why this would be happening, and consistency is critical in this case because all three sketch segments need to be drawn for the development of the rest of my macro.
bret = swModelDocExt.SketchOffsetOnSurface(EdgeDist1, False, True)
Do this for each Edge, and then get the sketch segments as shown:
Dim vSketchSeg As Variant
Dim swSketchSeg1 As SldWorks.SketchSegment
Dim swSketchSeg2 As SldWorks.SketchSegment
Dim swSketchSeg3 As SldWorks.SketchSegment
Set swSketch = swSketchMgr.ActiveSketch
vSketchSeg = swSketch.GetSketchSegments()
Set swSketchSeg1 = vSketchSeg(0)
Set swSketchSeg2 = vSketchSeg(1)
Set swSketchSeg3 = vSketchSeg(2)
bret = swSketchSeg1 .Select4(True, Nothing)
bret = swSketchSeg2.Select4(True, Nothing)
swSketchMgr.SketchTrim swSketchTrimChoice_e.swSketchTrimCorner, 0, 0, 0
The selection fails each time and I cannot seem to figure out what else to do to accomplish a successfull selection. I know that this trimming method isn't appropriate, but I can figure that out later.
I suppose my two main questions are, what else can I try to:
- Offset all (3) Edges consistently (assuming similar geometric conditions).
- Select and trim the new sketch segments to corners.
Thank you in advance, hope this makes sense.