Form not working

Hi,

I require assistance with the attached macro. The form gives the user an option to chose if he wants to cut the left or right side of the part.The form works fine if the line

( 'If strOpt = "No" Then)  is commented out.However if you remove the ' and add another end if at the bottom then the macro does not work.

Thank you

SolidworksApi macros
Answers 14
IK
IK 2013-11-24 Best Answer

You have defined strOpt two times (in module1 and in UserForm), so strOpt in Main is allways empty.

FM
FM 2013-11-25

Ivana,

The attached macro does not seem to work. The only problem I could see is that it was created in 2013 while I am using SolidWorks2012.

I have fixed the references to point to SolidWorks 2012 and it still does not work.

Thank you

FM
FM 2013-11-29

Help please

MK
MK 2013-11-29

Hi Feroz.

The macro works! The only thing you must note is that there ia s plane with the name -Right- in your model.

FM
FM 2013-11-29

Manfred,

After rechecking, I found that the macro works only if the plane is pre-selected. The idea behind the macro was to only split the part about the right plane.

MK
MK 2013-11-29

Feroz,

i have changed the macro to check if the plane is in the model and selectable. Otherwise you will see a message.

FM
FM 2013-11-29

Manfred,

Thanks for your assistance. I require the macro to work without having to select the plane as it should cut about the right plane by default.

MK
MK 2013-11-29

Feroz,

and so the macro works!! If there is a plane with the name RIGHT you must not select it!!! Please check the spelling of your plane name (Lower/Uppercase).

FM
FM 2013-11-29

Manfred,

Sorry for being a nuisance. The macro is not working on my side. Please see attached video.

MK
MK 2013-11-29

Please change the line

Boolstatus = swModel.Extension.SelectByID2("Right", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

in

Boolstatus = swModel.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

in the macro. The name of the entity you want to select in the Sw API must have the SAME name as in Fetauremanager design tree.

SF
SF 2013-11-29

Hi Feroz,

In the macro instead of

If Boolstatus = True Then

just use

If Boolstatus Then

"If Boolstatus = True" is evaluating to false so the macro is not working

FM
FM 2013-11-29

Santosh,

Thank you.This has solved the problem.

Thank you also to Ivana and Manfred for the assistance.

DG
DG 2013-11-29

Thanks Santosh for finding the issue, I've been messing with this macro but could not find out as why it is not working.

Thanks for sharing, learned something new 

FM
FM 2013-12-02

Thank you also to Deepak who was trying to assist outside this forum.