I've looked hard and experimented plenty but can't seem to get a sketch to position actually on the user-selected planar face. It seems like the sketch's support plane is parallel to the selected surface but running through the part's origin. Documentation indicates this would be the case too from what I can tell, but it also indicates that it is possible to place a sketch actually on the selected planar face. But the it's not clear that this can be done with VB. "Using a reference allows to create a sketch either on an element, as here the XY plane, or on a solid planar face that is not directly accessible as a VB object."
I have a simple pad, the user is prompted to select a surface, the surface is selected and the macro creates a geoset, sketch, and line geometry. But the sketch is created in the Z=0 plane and not in the plane on 'top' of the pad, the surface that was selected at Z=1.0. Is this as good as it gets using VBA to do this? Funny thing is I have a Powercopy that performs this function well. The user selects a surface and point and the sketch is inserted there. I'm trying to replicate this in VB or VBA and add some functinality that can't be accomplished with a Powercopy. ASSuming there is a way to accomplish sketching on a solid planar face my next problem will be moving the sketch origin around in that plane.
This is the code portion that is relevant;
Dim status As String
Dim filter(0)
filter(0) = "PlanarFace"
status = sel.SelectElement2(filter, "Select Plane", False)
...
Dim sketches1 As Sketches
Set sketches1 = hybridBody1.HybridSketches
Dim reference1 As Reference
Set reference1 = sel.Item(1).Value
Dim sketch1 As Sketch
Set sketch1 = sketches1.Add(reference1)
Dim arrayOfVariantOfDouble1(8)
arrayOfVariantOfDouble1(0) = 0#
arrayOfVariantOfDouble1(1) = 0#
arrayOfVariantOfDouble1(2) = 0#
arrayOfVariantOfDouble1(3) = 0#
arrayOfVariantOfDouble1(4) = 1#
arrayOfVariantOfDouble1(5) = 0#
arrayOfVariantOfDouble1(6) = -1# 'always point in negative x direction
arrayOfVariantOfDouble1(7) = 0#
arrayOfVariantOfDouble1(8) = 0#
Set sketch1Variant = sketch1
sketch1Variant.SetAbsoluteAxisData arrayOfVariantOfDouble1
myPart.InWorkObject = sketch1
Dim factory2D1 As Factory2D
Set factory2D1 = sketch1.OpenEdition()
Dim geometricElements1 As GeometricElements
Set geometricElements1 = sketch1.GeometricElements
Dim axis2D1 As Axis2D
Set axis2D1 = geometricElements1.Item("AbsoluteAxis"
Dim line2D1 As Line2D
Set line2D1 = axis2D1.GetItem("HDirection"
line2D1.ReportName = 1
Dim line2D2 As Line2D
Set line2D2 = axis2D1.GetItem("VDirection"
line2D2.ReportName = 2