Page 1 of 1

How to select coordinate system plane using API

Posted: Wed Dec 06, 2023 10:59 am
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

Re: How to select coordinate system plane using API

Posted: Thu Dec 07, 2023 5:37 am
by RonE
This seems to be a limitation. I also didn't find a way to select the COORDSYS planes or axes via API.

Re: How to select coordinate system plane using API

Posted: Thu Dec 07, 2023 8:19 am
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