I have a simple macro that draws a circle on the right plane for me. Make that HAD a macro...
Ever since upgrading to sw2020 (from 2019) my "circle on right plane" macro has been broken. It creates a circle like it should, but on the front plane.
I can manually edit the sketch plane and manually select the right plane, but then that defeats the purpose of a macro.
I've used this macro probably since 2018, possibly earlier.. its always worked before the upgrade to 2020.
Ideas?
SolidworksModeling And Assemblies
Following up.. I tried re-creating the macro and get exactly the same result. Then, I got curious and created a 2nd macro using the Top plane, and it's doing the exact same thing, defaulting back to using the front plane only.
I also created a quick screen cap while running the macro, watch closely and you can see the software select and create the circle on the right plane, then it quickly switches to the Front.
In the macro editor, editing my original Circle On Right.swp, it clearly says in the code "Right Plane" .
WTH? Anyone?
Finally got around to looking at this again & swapping the line order, as suggested, worked. No other changes necessary.
Thanks for the guidance!
I would say that name should override the coordinate, but those are not except each other, i.e. selection point also matters so you can select an object by name and also have its selection point. So I suspect in this case it just cannot satisfy this requirement and switching the order of lines changes the condition somehow.
My understanding is that the name overrides the co-ordinates. That is not true? As I found that if I switched the two lines of code, it selected the right plane correctly.
I looked at the plane select method in your link. This would be how I would have done it (although my code would not have been as polished as yours).
Ok... thanks for the suggestions.
I will say that Im not a programmer or scripter, so the API stuff is slightly over my head.. I simply used the macro recorder to make this macro, & solidworks chose what methods it used to render the macro code.
What is irritating is this macro worked as indented in every version of solidworks prior to 2020.. something changed, and it wasn't my macro.
I'll try implementing some of these suggestions tomorrow & report back w my results.
Thanks!
Remove coordinates as this is how SW tries to select the plane and depending on the orientation of the screen - wrong entity could be selected:
boolstatus = Part.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
The better way to select standard plane is shown here: Select standard plane (e.g. Front) by type using SOLIDWORKS API (check SelectPlane function)
In general try to avoid SelectById2. Check this for more information about selections:
Sketches the circle on the front plane for me in SW2018. However if I flipped these two lines of code, the circle sketch is created on the right plane. Not sure why it sketches the circle on the right plane for you.