Hi there,
I would like to create automaticly a boundary surface on a sketch. For this I have some preparations, such as automatic search for points and create a 3Dsketch.
But when I create a boundary surface between two lines while record it with the macro recorder, I'll get an error when I run that recorded code.
VB:
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0.013, 0, 0.00591299267694, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0.055, 0, 0.01, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0, 0, 0, True, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0.013, 0, 0.00591299267694, False, 12289, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0.055, 0, 0.01, True, 24577, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Unknown", "SELOBJGROUP", 0, 0, 0, True, 12290, Nothing, 0)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.SetNetBlendCurveData(0, 0, 0, 0, 1, True)
Set myFeature = Part.FeatureManager.SetNetBlendCurveData(0, 1, 0, 0, 1, True)
Set myFeature = Part.FeatureManager.SetNetBlendDirectionData(0, 32, 0, False, False)
Set myFeature = Part.FeatureManager.SetNetBlendCurveData(1, 0, 0, 0, 1, True)
Set myFeature = Part.FeatureManager.SetNetBlendDirectionData(1, 32, 1, False, False)
Set myFeature = Part.FeatureManager.InsertNetBlend(2, 2, 1, False, 0.0001, False, True, True, True, False, -1, -1,False, -1, False, False, -1, False, -1, False)
End Sub
The error I get is an COMexception error at the line with InsertNetBlend (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
Later on, I translate this code to C#, because my macrorecorder doesn't record at such langauge.
C#:
public void Main() {
ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc; SelectionMgr swSelmgr = (SelectionMgr)swModel.SelectionManager; bool boolstatus = swModel.Extension.SelectByID2("Line2@3DSketch3", "EXTSKETCHSEGMENT", 0.055, 0, 0.002, false, 1, null, 0);
boolstatus = swModel.Extension.SelectByID2("Line1@3DSketch3", "EXTSKETCHSEGMENT", 0.013, 0, 0.002, true, 1, null, 0);
boolstatus = swModel.Extension.SelectByID2("Line1@Sketch1", "EXTSKETCHSEGMENT", 0.022, 0, 0, true, 2, null, 0);
FeatureManager swFeatMgr = (FeatureManager)swModel.FeatureManager;
swFeatMgr.SetNetBlendCurveData(0, 0, 0, 0, 1, true);
swFeatMgr.SetNetBlendDirectionData(0, 32, 0, false, false);
swFeatMgr.SetNetBlendCurveData(1, 0, 0, 0, 1, true);
swFeatMgr.SetNetBlendDirectionData(1, 32, 0, false, false);
swFeatMgr.InsertNetBlend(2, 2, 1, false, 0.0001, false, true, true, true, false, 0, 0, false, 1, false, false, 0, false, 0, true); }/// /// The SldWorks swApp variable is pre-assigned for you. /// public SldWorks swApp;
And again the error appears at the line with InsertNetBlend.
I searched the whole net, but it seems that no one use a macro like this or doesn't have any problem. But I cann't find the source of this problem.
Please help me....
Kind regards, Coert van den Bors
SolidworksApi macros