AnsweredAssumed Answered

Handling multiple file types within a macro / macro feature

Question asked by Kevin Collins on Apr 27, 2016
Latest reply on Jan 23, 2017 by Brian Smith

Hey all,


I came to you guys because I know you're the smartest SW API users around!

I have a bounding box macro feature designed to find the overall dimensions of a part and export them to the custom properties.

The macro feature is embedded in the part template and it works great, for the most part.

The macro feature is also programmed to re-order itself to the bottom of the tree so that any and all changes to the part are captured.


After multiple rounds of error handling, I have the macro running to the point where it no longer errors out in any scenario I am likely to run across.

That said, however, I do have an issue.  If I change dimensions of a part within the part file, the updated values export without issue.

The point at which I run into a problem is if I try editing a part within an assembly.

There are no errors, however, the values will not update unless I manually go into edit feature on the part file outside of the assembly and rebuild the feature from there.

I think I understand why this is happening.  The following line of code tells SW to skip everything if the active file type is an assembly or drawing file:


The problem is, if I remove this line of code, or comment it out, the part template which contains the feature will error out if an assembly or drawing file are open at the time of trying to create a new part.


Does anyone know of an easy way around this?


Does anyone know if the method "Getbodies2" will work on assembly or drawing files, or is this specific to part documents?


I've attached the macro in it's current state if anyone can shed any light it would be appreciated.  I am being pushed to have this up and running by the end of the week.


Thanks all!