Tutorial to turn Macro into DLL?

Does anybody have a tutorial for turning a Macro into a DLL? Apparently there was one at

formatting link
but it seems to have been removed.

Reply to
Ant.
Loading thread data ...

If you look on SolidWorks.com

formatting link
, anything referencing adding menus will show you the basic structure.

Reply to
Evan T. Basalik

Thanks Evan, but I need something that starts from the beginning and describes the process. Any other thoughts?

Regards,

Anthony

Reply to
Ant.

Project to take existng macro and turn it into an addin with toolbars and menu picks. Includes macro source, toolbar bitmaps, and other resources.

Pay special attention to how you structure your macro. Do what you can to make it "addin ready" (this is discussed in the Powerpoint presentation).

Reply to
That70sTick

Thanks Roland. By the way I'm having some trouble with my macro. The goal is to start with a drawing, open the associated part, and read out some custom properties of the part. For some reason the macro only works if you have already opened the part in your current session (even if you've since closed it). The offending lines are:

'Open and activate the referenced Model Set swDrawModel = swApp.OpenDoc6(ModelName, DocType, swOpenDocOptions_Silent, "", nErrors, nWarnings) Set swDrawModel = swApp.ActivateDoc2(ModelName, False, nRetval) ClientCode = Trim(swDrawModel.CustomInfo2("", "ClientCode"))

The error message is "Object variable or with block variable not set", and the offending article is 'swDrawModel.CustomInfo2(...'

Any ideas?

Reply to
Ant.

Roland - don't worry, I just debugged it. Apparently you can't use the full file path in the ActivateDoc2 command. Substituting a string called sModelName (model name only, no directory info) into the ActivateDoc2 command got it working.

Thanks for the Powerpoint, its awesome. Wish I'd been there, as I'm not clear on some of the steps. Will post any questions.

Regards,

Anthony

Reply to
Ant.

I'm not sure you need to use ActivateDoc2 after opening the document, since OpenDoc6 already sets the swDrawModel object to the desired file. Maybe do a quick check to verify that the newly opened doc is active before activating it (again). The trouble with ActivateDoc2 and the path name is puzzling, as it should work with the full path name.

If you need to be sure the doc is activated, perhaps use ModelDoc2::GetTitle or ModelDoc2::GetPathName to get the name string.

Reply to
That70sTick

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.