Question For Wayne Tiffany

Hi Wayne

I'm trying to use your BoundingBox.swp but it keeps failing, and I'm no guru when it comes to VB.

I get a Microsoft Visual Basic Compile Error popup message "Object Library Feature Not Supported". It appears to stop at

"Set swApp = CreateObject("SldWorks.Application")" line in the Sub Main() part of the code.

I'm using SWX2005 SP3 on a Win 2000 SP4 PC.

Any help would be much appreciated.

Regards Brian

Reply to
McBrian
Loading thread data ...

Did you set the type library and constant library first? Found in Tools/References in the macro editor.

Reply to
TOP

Did this suggestion help? You should set the reference to the proper version of the files that matches your installed SW version. If not, let us know.

WT

Reply to
Wayne Tiffany

Hi Guys

Thanks for the replies. The references appear to be correct, "c:\program files\solidworks\sldworks.tlb" for the Solidworks 2005 Type Library and "c:\program files\solidworks\swconst.tlb" for the Solidworks 2005 Constant Type Library. Can't see the version of these files but they were both created on 14/04/2005. I have tried to run the macro on five different installations (all SWX 2005 SP3) and get the same error on them all. All my other macros appear to work fine.

Regards Brian

Reply to
McBrian

Hi Again

Ok! I found a 2005 SP0.0 installation in another office, and HEY! no problem, works OK, just what were looking for (you code masters are a god send). I copied the 2 tlb files, renamed the ones in my installation and pasted the SP0.0 files into my SWX installation folder, and yup it works, SWX sucks sometimes.

Now! how do I change it to list centimeters instead of millimeters in the custom properties ( the model is and always will be created in millimeters/grams). At the moment we manually add these bounding box dims as reference dims and change the properties to centimeters with one decimal place, this is then listed on the drawing by a linked note in the border template.

Your help is much appreciated.

Regards Brian

Reply to
McBrian

Interesting thought - I don't think you can. The program respects the user selected units of the model and since the evaluated value of the custom properties is tied directly to properties, it will evaluate to the document units. You could add a routine that creates a new property by factoring the existing property and assigning a value to it, but then it would be a stupid number - not tied to anything active. If the geometry changed, that fudged value would not update on its own.

Now, an even more interesting happening - the macro won't run on my SW2005 SP5.0 installation either! Same error you are seeing. It appears that something has changed in that the method I used in this macro to attach to SW isn't valid any more. Other macros still work, and this one works in SW

2006 SP3.0 by merely changing the referenced files. Hmmm - time to turn it in.

WT

Reply to
Wayne Tiffany

Brian, I would do the following to make BoundingBox.swp add properties in CM when doc units are MM.

Do this in new macro BoundingBoxMM.swp by creating blank macro and cutting and pasting entire boundingbox.swp.

1) Comment/delete 'Select Statement' that gets document's units (mm in this case) 2) Add ConvFactor line immeadiately after select statement.

'Select Case Part.GetUnits(0) ' Case swMM ' ConvFactor = 1 * 1000 ' Case swCM ' ConvFactor = 1 * 100 ...

ConvFactor = 1 * 100 'assign ConvFactor to be equivalent to when doc units = cm.

This overrides the user units for this macro. You can also do similar comments and override values for the messageboxes and answers.

----------------------------------------------- Wayne, I'm very impressed with bound You could add a routine that creates a new property by factoring the

Does this mean the properties created by BoundingBox.Swp stay current when dimensions are changed after the macro is ran?

I'm using boundingbox.swp with this in the header. ' * Modified by Wayne Tiffany, Oct 12, 2004 ' * Updated 10/15/04 Is this the latest?

Thanks for creating this Macro and contributing so regularly on the forum.

Sincerely, Blair

Reply to
Blair Sutton

Brian, I would do the following to make BoundingBox.swp add properties in CM when doc units are MM.

Do this in new macro BoundingBoxMM.swp by creating blank macro and cutting and pasting entire boundingbox.swp.

1) Comment/delete 'Select Statement' that gets document's units (mm in this case) 2) Add ConvFactor line immeadiately after select statement.

'Select Case Part.GetUnits(0) ' Case swMM ' ConvFactor = 1 * 1000 ' Case swCM ' ConvFactor = 1 * 100 ...

ConvFactor = 1 * 100 'assign ConvFactor to be equivalent to when doc units = cm.

This overrides the user units for this macro. You can also do similar comments and override values for the messageboxes and answers.

----------------------------------------------- Wayne, I'm very impressed with bound You could add a routine that creates a new property by factoring the

Does this mean the properties created by BoundingBox.Swp stay current when dimensions are changed after the macro is ran?

I'm using boundingbox.swp with this in the header. ' * Modified by Wayne Tiffany, Oct 12, 2004 ' * Updated 10/15/04 Is this the latest?

Thanks for creating this Macro and contributing so regularly on the forum.

Sincerely, Blair

Reply to
Blair Sutton

Updated 10/15/04 is the latest version that I have.

Ok, I actually took a look at the way I wrote it back then and I see that my previous answer wasn't proper - sorry, bad memory.

Every time you run the program, it queries the geometry to find the rough outline using a SW API call. Then it converts the return values (which are always in meters) to whatever the user units are in the document. The individual properties are then created as numbers, not properties, so they are totally stupid as far as no updating. If you use the default property, it creates it as text, but stuffs in numbers, not properties. If the 3D sketch is used, it's also stupid and it will create a new one each time the program is run.

So, Blair's answer about the cm question is correct - just hard code it to always convert the numbers to cm. You don't have to create a new macro unless you want to retain a copy of the old one also.

Also keep in mind that the program adds a small amount to all 3 dimensions and this value is changeable to suit your needs. In the section titled Main(), the next line has a variable called AddFactor - just change the default .015 to whatever you wish. It can also be 0 if desired.

WT

Reply to
Wayne Tiffany

I pursued this through our VAR to APISupport at SW and they replied with the following:

"This issue is now fixed. Please remove the SldWorks type library reference, close the references dialog, add it back again, and save. This should fix the issue. I apologize for the inconvenience."

Ok, I tried it and it did fix the problem on my machine. So I wrote back and asked why since the fix made no sense to me. If I receive more info, I'll update you. Otherwise just do the fix and enjoy it.

WT

Reply to
Wayne Tiffany

I asked the question of the proper person at SWW and got an answer as to why this procedure worked. When you save a macro, it compiles a certain amount of information into the macro and saves it with the macro file. Now, somewhere about SP3 or 4, they made a change to the type library such that the newer versions would not read properly without recompiling. So, following the procedure forced the macro to reread and recompile the info, thereby allowing it to properly read the type library file.

And now you know the "rest of the story." :-)

WT

Reply to
Wayne Tiffany

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.