Recover solidworks property

How do I retrieve the value of a property in Solidworks?

 

(the command to add one is: swModel.AddCustomInfo3("", "Test", swCustomInfoText, "1") )

 

To then put a condition:

- If the value of "Trial" = 1

    Then new property: swModel.AddCustomInfo3("", "Reponse1", swCustomInfoText, "OK")

- If the value of "Trial" = 2

    Then new property: swModel.AddCustomInfo3("", "Answer2", swCustomInfoText, "OK")

I don't know what your SolidWorks properties correspond to but:

You can manage the conditions via the "Smarpropertie" utility you use the "option" and/or "conditional" commands


smarproperties.png

yes, I know SmartProperties.

But this is special... I have to go through a macro before making a Smart.

So I'm looking for the "raw" VBA code to read the property.

Hello

Indeed, as flegendre says, the "SmartProperties" utility does this very well.

You can also achieve this kind of processing by using the SolidWorks "Custom Properties" feature that you can find in the task pane. but it's a little more complicated than "SmartProperties"!

Kind regards


proprietes_perso_sw.png

Drat! Crossed answer.

Yes, thank you, but as said just before, it's really the VBA code (same as swModel.AddCustomInfo3) that I'm looking for

Damn, crossed again...

1 Like

I tried:

 

If swCustomPropertyNames("Trial") = "1" Then
bRet = swModel.AddCustomInfo3("", "Response1", swCustomInfoText, "OK")
 
But it doesn't work...

Hello

 

I guess this request is related to this one:

 

http://www.lynkoa.com/forum/emplacement-fichiers-xml?page=1

 

The last answer I gave didn't help you?

I really have a hard time understanding why you absolutely want to go through a macro?

 

I know that's a lot of questions but if it can help the chmimblick move forward...

 

@+

 

1 Like

Yes, it's related.

 

My observation is simple: the SmartProperties link is managed ONLY according to the type of room.

 

So, I make a macro that will change the "XmlPath" property and therefore the direct path of the SmartPorperties according to a property:)

 

I'm almost there, I just need to create this condition (read the prop then new prop)
If you can help me

Hello

 

 

To retrieve a property, the statement is:

                SWmoddoc. GetCustomInfoValue("", "code")


We get the "code" property in the VBA variable "CODE", where SWmoddoc represents your active document (Set SWmoddoc = swApp.ActiveDoc).

 

For the basic macro instructions, I advise you to read carefully the tutorial I made and which is commented on for each line:

 

http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks

 

Re

 

But it's not only related to the type of part, (in my example it's the case) but I'm talking about a property that drives an XMl and seems to me that it's what you want!

This property can be any not THAN the type of part...

 

Or I really don't understand ANYTHING about the question!

 

@+

With an image..


smartproperties2.jpg

@Coyote: Yes, currently I'm using your drop-down method to choose the xml.
But it's not clear to users...

For example, when you make a part, in this list you can put "PieceCommerce" and "PieceManufactured". And it's when you launch the Smart that you make your choice. And that every time you relaunch it...

 

Whereas by going through a template (where the "PieceCommerce" property is entered permanently), the Smart voucher is launched automatically and every time. And what's more, it's blind for the user. 

Ha Ok it's clear I understand the need much better.

 

Well, I'm trying to see if I find the right solution.

 

@+

A priori, it works at the top

 

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

 

Once finalized, I try to put the result in the other topic if people are interested

1 Like

Yes, I'm interested in your thewarner macro !

Please let me know when it is available.

Available

 

(but it's very simple actually...)