api question

I hae the following code for a macro

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc boolstatus = Part.Extension.SelectByID("", "FACE", -22.25058668939,

5.223159153259, 2.532190636408, False, 0, Nothing) Part.ShowNamedView2 "*Normal To", 0 Part.NameView "X", -1 boolstatus = Part.Extension.SelectByID("Default@PANEL 5.SLDPRT", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing) Part.ClearSelection Part.ShowConfiguration "Default" Part.ShowNamedView2 "*Dimetric", 9 End Sub

But I get an error for this line "Part.NameView "X", -1" the error is runtime error450 wrong number of arguments or invalid assignment.

HELP???????

While I am at it, how do I get a macro to pause and ask me to choose a face and then continue on? you can see this macro starts with a face selcected, I have another macro to run before it and would like the two macros to be joined but what is stopping me is the selection of the face in the middle of the potentially combined macro.

TIA Ben

Reply to
Ben
Loading thread data ...

Refer to API help, look for NameView function: ---8

Reply to
Heikki Leivo

Sub main () Load UserForm UserForm.Show False End Sub

Now if you want notification so that you can do something after a selection without another click. then declare your part like this.

Public WithEvents Part As SldWorks.AssemblyDoc

Private Function Part_NewSelectionNotify() As Long 'put everything you want to happen after a selection here 'check that the selection is a usable surface 'if so continue the next part of your macro End Sub

Corey Scheich

Reply to
Corey Scheich

-h-

I never put the -1 in the macro, it was there after I recorded it. None the less when I try and get rid of it I get a compile error: expected expression. Thank you for your help, maybe I can make some sense of this now that I have had a few beers and a good sleep.

AHHHHH HA! being the details oriented guy I am I removed the -1 and.... get this... the comma before the -1 and all is good...lol sometimes I hate it when you mistake a comma or decimal for a spec of garbage on your screen.. that's my excuse and I am sticking to it.

On a serious note I am not sure why the recording put that -1 there.... any ideas?

By the way what is the VBA book to read and learn from for SW?

Ben

Reply to
Ben

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.