VBA.In a drawing, how do you get the properties of the part?

Hello

I would like to be able to obtain the properties of the part on my drawing, how do I do it?

Because the purpose is that I want to get these properties to rename my pdf, when I convert my drawing to pdf.

Kind regards

Just put notes with the desired properties.

 

As an example, I took a note and added a property of my questionnaire to it.

 

But you can take any property.


note.png
2 Likes

Bart, I think he wants to run a macro to save his mep as a PDF. And that in the name of this PDF appear some properties of the part.

 

That said, I don't know how to do it. Maybe you'll find the beginning of an answer in the vba explorer (it helps a lot)

 


explorateur_objet.bmp
2 Likes

Hello

coin37coin, you're right it's to launch a macro that converts my plan, composed of several sheets, into several pdfs that are renamed according to the recover properties.

But still today, with the help of API, I have tested several things, but nothing conclusive for the moment, I have just managed to recover the path of the placement of the part which is on my drawing.

I'm sticking you in a link a question that is quite close to yours is that seems to be answered on the forum (. Pl grand master of the vba!)

 

You'll tell me if it works but apparently yes

 

http://www.lynkoa.com/forum/3d/recuperer-propriete-solidworks

1 Like

Hello

coin37coin, thanks for the info and the link but I had already read this link before, 

and indeed it works well on an open room but not on a drawing...,

So I'm still looking for...

2 Likes
Still no solution? If so, I can look for it. In the first view of the drawing you have to activate the first view of the drawing to retrieve the name of the part, only then can you retrieve the custom properties.
1 Like

Hello

Thanks .PL it's true, I manage to get the entire path of the piece, I'll try to start from the name obtained to get the custom properties tomorrow.

Sorry even if I found another way to get the information I wanted, I didn't close the question because the basis of the question was not really solved.

I'm trying to do all this tomorrow and I'll close.

1 Like

Hello

Thanks .PL it's true, I manage to get the entire path of the piece, I'll try to start from the name obtained to get the custom properties tomorrow.

Sorry even if I found another way to get the information I wanted, I didn't close the question because the basis of the question was not really solved.

I'm trying to do all this tomorrow and I'll close.

Here is the procedure I use to retrieve the custom property " code " from a drawing :

 

' #####################################################################

'part for retrieving personal properties'

We activate the 3D for the retrieval of the information

' ##########################################

Set swApp = Application.SldWorks

Set CurrentDOC = swApp.ActiveDoc' retrieves the current document

Set swModel = swApp.ActiveDoc

Set swConfigMgr = swModel.ConfigurationManager

Set swDraw = swModel

Set swView = swDraw.GetFirstView

Set swView = swView.GetNextView 'enables/retrieves the first view for custom properties

Set swRefDoc = swView.ReferencedDocument  ' We now have swRefDoc the 3D of the drawing

CODE = swRefDoc.GetCustomInfoValue("", "code")

Thank you so much to .PL!