About REFSURFACE in C#

I need to insert a offsetsurface of a " REFSURFACE " which I inserted using InsertPlanarRefSurface() .

I get a API sample from SW in VBA below

Sub main()

Set swApp = _

Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.00645152344201, -0.02252514488873, -0.04027607412763, True, 0, Nothing, 0)

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.00645152344201, -0.02252514488873, -0.04027607412763, False, 1, Nothing, 0)

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.00645152344201, -0.02252514488873, -0.04027607412763, False, 1, Nothing, 0)

boolstatus = Part.InsertPlanarRefSurface()

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("", "FACE", 0.002650717582966, 0.003599192305103, -0.04000000000008, True, 0, Nothing, 0)

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("", "FACE", 0.002650717582966, 0.003599192305103, -0.04000000000008, False, 1, Nothing, 0)

End Sub

as you can see in VBA the REFSURFACE was selected as " FACE " , but when I use the nearly same way in C# to select the REFSURFACE, I always get false.

boolstatus = swModelDocExt.SelectByID2(name1, "FACE", 0, 0, 0, true, 0, null, 0);    //name1 is the name of RefSurface I inserted     get false

swModel.ClearSelection2(true);

boolstatus = swModelDocExt.SelectByID2(name1, "FACE", 0, 0, 0, false, 1, null, 0);   //get false

swModel.InsertOffsetSurface(thick, reverse);                        //nothing was inserted after this

can anyone help?

SolidworksApi macros
Answers 4
SF
SF 2011-10-19 Best Answer

Why dont you use the enumeration swSelREFSURFACES? At least that looks like it would be the right one I have not tried

SF
SF 2011-10-21

Hi, David,

Thank you for your advice, I can get boolstatus true if I use that, but the problem is swModel.InsertOffsetSurface(thick, reverse); dont insert anything, after I do that, so I think maybe I should follow the macro use FACE, and I always get false......

SF
SF 2011-10-25

Try using "SURFACEBODY" instead of "FACE"

SF
SF 2011-10-26

Hi, Piotr

Thank you for your advice, I have solved my problem in another way. The macro got from SW was no use in my problem.

I have to say C#  and VBA  are really different....