Access to Component "File Properties" Through Assembly & Drawing Without Opening the Component

Library for macros
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 39
x 20

Access to Component "File Properties" Through Assembly & Drawing Without Opening the Component

Unread post by Slasher »

Hello everyone,

Basically a macro for the subject says. I searched the forum library but could not find something similar.

I have Custom Properties setup which is great but it does not work in drawings environment o[ .
This forces me to switch back & forth a lot when I want to change properties of a component; say description, finishing note, etc.

Ideally precondition would be to pre-select an entity of the component from graphics view (for both assembly & drawings).
It'd be nice if you can select the component from BOM in drawing environment and the macro still works.

Thank you in advance!
Vahid
User avatar
AlexB
Posts: 493
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 27
x 265
x 440

Re: Access to Component "File Properties" Through Assembly & Drawing Without Opening the Component

Unread post by AlexB »

This example shows how to get a component within the drawing view. You could also explicitly select it and use the GetSelectedObject functionality and cast the current selection as needed.

https://help.solidworks.com/2018/englis ... ple_vb.htm

From there, you can use the Component2::GetModelDoc2() function to get the pointer to that component's model. You should be able to get the custom property manager from there similar to your current macro.
Post Reply