How to select coordinate system plane using API

Programming and macros
Halasox
Posts: 14
Joined: Mon Nov 28, 2022 7:10 am
Answers: 0
x 9
x 9

How to select coordinate system plane using API

Unread post by Halasox »

I am trying to select a plane of a created coordinate system and then normal to it. It only works manually doing it, but not using API! o[

Appreciate any help!

Code: Select all

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("Coordinate System1\YZ Plane", "COORDSYS", 0, 0, 0, False, 0, Nothing, 0)
swApp.RunCommand swCommands_NormalTo, ""
Part.ClearSelection2 True
End Sub
User avatar
RonE
Posts: 32
Joined: Wed Nov 17, 2021 10:02 am
Answers: 4
Location: Germany
x 18
x 33

Re: How to select coordinate system plane using API

Unread post by RonE »

This seems to be a limitation. I also didn't find a way to select the COORDSYS planes or axes via API.
User avatar
SPerman
Posts: 2080
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2256
x 1902
Contact:

Re: How to select coordinate system plane using API

Unread post by SPerman »

My guess is that you are going to have to get more sophisticated and use the solidworks transform functions.

This might help you get the vector normal to the plane. (I'm not sure if the problem is with the selecting of the plane or the NormalTo command.)

https://help.solidworks.com/2017/englis ... ormal.html
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Post Reply