Hello everyone,
I have a macros that automatically names every new part or assembly created. For example- I choose template that names part- 100,101 etc. and other template names assembly- XX-1, XX-2 etc. However when making new part in assembly everything works fine, macros names part as it should, but when creating subassembly from components macros doesn't work. Is there anyway I can make macros recognize subassembly as an assembly? Or maybe there is some other way around this?
Thanks.
Macro for new file naming
-
- Posts: 7
- Joined: Wed Dec 01, 2021 5:54 am
- x 2
-
- Posts: 98
- Joined: Thu Mar 18, 2021 11:19 am
- Location: St. Louis, MO
- x 288
- x 56
Re: Macro for new file naming
Don't know if there's a quicker way, but you can get the component's ModelDoc, IComponent2::GetModelDoc2, then determine the document type via the IModelDoc2::GetType Method. Someone please correct me if I'm wrong, as I've not done this before!
Austin
-
- Posts: 7
- Joined: Wed Dec 01, 2021 5:54 am
- x 2
Re: Macro for new file naming
Thank you for responding! Can you tell me more about this? I'm really new into macros and don't know a lot of things.
Thank you.
Thank you.
-
- Posts: 98
- Joined: Thu Mar 18, 2021 11:19 am
- Location: St. Louis, MO
- x 288
- x 56
Re: Macro for new file naming
Sure thing...I can't really go into too much detail, as most of my macros are at the part level, so forgive me for that. From what I understand, SolidWorks API considers parts AND subassemblies as "components" within an assembly. So, you need to get each of the assembly's components, and determine if that component is a part or assembly (subassembly). My guess is to use the methods that I listed above. Make sense?Wasermelone wrote: ↑Fri Dec 10, 2021 1:25 am Thank you for responding! Can you tell me more about this? I'm really new into macros and don't know a lot of things.
Thank you.
Austin