SW macro
SW macro
(OP)
hi
I have made this macro to plot some points in a sketch, but depending on if there is zoomed out or in, it will plot it wrong or right.
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
A = 0.3
B = 0.3
X = 0
C = 0
Y = 0
K = 0.8
ST:
X = X + 0.1
Y = A * X ^ 2 + B * X ^ 2 + C
Part.CreatePoint2 X, Y, 0
If X < K Then GoTo ST
End Sub
I have made this macro to plot some points in a sketch, but depending on if there is zoomed out or in, it will plot it wrong or right.
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
A = 0.3
B = 0.3
X = 0
C = 0
Y = 0
K = 0.8
ST:
X = X + 0.1
Y = A * X ^ 2 + B * X ^ 2 + C
Part.CreatePoint2 X, Y, 0
If X < K Then GoTo ST
End Sub






RE: SW macro
By the way, what programming language are you used to? Using GoTo to create a loop is generally considered poor programming practice in VB/VBA.
-handleman, CSWP (The new, easy test)
RE: SW macro
yes it is poor programming, but im also new to this ;O)
RE: SW macro
RE: SW macro
CODE
Dim swApp As Object
Dim Part As SldWorks.ModelDoc2
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Part.SetAddToDB True
Part.SetDisplayWhenAdded False
A = 0.3
B = 0.3
X = 0
C = 0
Y = 0
K = 0.8
ST:
X = X + 0.1
Y = A * X ^ 2 + B * X ^ 2 + C
Part.CreatePoint2 X, Y, 0
If X < K Then GoTo ST
Part.SetAddToDB False
Part.SetDisplayWhenAdded True
End Sub
-handleman, CSWP (The new, easy test)
RE: SW macro
RE: SW macro
http://www.sdcpublications.com/1-58503-263-8.htm
ht
I own the first one and it is pretty good for an introduction and is available from amazon.com. The second one is pretty new.
-Dustin
Professional Engineer
Certified SolidWorks Professional
RE: SW macro
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group