First API project attempt -- crash and burn. :)

46 views
Skip to first unread message

aaronjs

unread,
Jun 5, 2009, 8:43:27 AM6/5/09
to SolidWorks-API
Quick question with my first full on brush with the API.
I have both photoworks and animation/simulation open.

I start the macro recorder to record a sequence of events.
I stop the macro recorder, saving the macro

I go to view the macro and play it and it won't "compile"

it gets stuck on:

Dim pwPhotoWorks As PhotoWorks.Photoworks

with the error dialogue:

Compile Error User-Defined type not defined



I assumed that a recorded macro was a playable macro... I'm
accomplishing very little with the code pasted below, as it is very
simple. However, I don't understand why a recorded macro isn't
compilable.

Any thoughts? Is this something simple I'm missing?


From the recorded code:
'
******************************************************************************
'
'
******************************************************************************
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
Dim pwPhotoWorks As PhotoWorks.PhotoWorks
Set pwPhotoWorks = swApp.GetAddInObject("PhotoWorks.PhotoWorks")
Dim pwOpt As PhotoWorks.PwOptions
Set pwOpt = pwPhotoWorks.PwOptions
Part.ClearSelection2 True
Dim motionStudyMgr As Object
Set motionStudyMgr = Part.Extension.GetMotionStudyManager()
Dim myMotionStudy As Object
Set myMotionStudy = motionStudyMgr.GetMotionStudy("LN2 Study")
boolstatus = myMotionStudy.SetTime(1)
End Sub

John Greiner

unread,
Jun 5, 2009, 11:32:52 AM6/5/09
to solidwo...@googlegroups.com
The compiler doesn't know what PhotoWorks is. You need to add a
reference to the PhotoWorks API to your VBA project.

From your VBA project, Tools->References and check the box next to
PhotoWorks 2009 Type Library. Then click OK.

Try to run your project, it should work.

John Greiner

--
John P. Greiner
Mechanical Engineer
503.866.8109

Reply all
Reply to author
Forward
0 new messages