If a custom property has associative dimension, how would I get the value and not the dimension name

Programming and macros
ResidentAtLarge
Posts: 35
Joined: Wed Jun 02, 2021 4:31 pm
Answers: 0
x 31
x 30

If a custom property has associative dimension, how would I get the value and not the dimension name

Unread post by ResidentAtLarge »

I am looking to link basic length and width as a custom property. So, the dimension that determines those two values are linked in the custom property which would look something like this: "Length@Sketch1@Part1" and "Width@Sketch1@Part1".

So, when writing my code it doesn't copy the Evaluated value of the custom property, it copies the "Value/Text Expression".
Is there a way to grab the Evaluated value instead of the text expression in the custom property?

The current code I'm using is :

Code: Select all

swCustProp.Get4("Width", False, val, valout)
I am using this macro to copy data into an excel database that I've created and based on a few custom properties that are concatenated, it returns data back into solidworks. A lot of the solidworks designers here like to link dimensions to their properties to use in their BOM and I'd like to keep it that way.
by Eddy Alleman » Thu Aug 19, 2021 9:01 am
Hi,

the valout schould give you the value
val gives what is filled in and that can be an equation in your case.

from the docs:
Parameters
FieldName
Name of the custom property
UseCached
True if the configuration has been activated, false if not (see Remarks)
ValOut
Value of the custom property
ResolvedValOut
Evaluated value of the custom property

The terminology is a little confusing...

Eddy
Go to full post
User avatar
Eddy Alleman
Posts: 44
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 78
x 86
Contact:

Re: If a custom property has associative dimension, how would I get the value and not the dimension name

Unread post by Eddy Alleman »

Hi,

the valout schould give you the value
val gives what is filled in and that can be an equation in your case.

from the docs:
Parameters
FieldName
Name of the custom property
UseCached
True if the configuration has been activated, false if not (see Remarks)
ValOut
Value of the custom property
ResolvedValOut
Evaluated value of the custom property

The terminology is a little confusing...

Eddy
ResidentAtLarge
Posts: 35
Joined: Wed Jun 02, 2021 4:31 pm
Answers: 0
x 31
x 30

Re: If a custom property has associative dimension, how would I get the value and not the dimension name

Unread post by ResidentAtLarge »

I've always been using val in my macro. I just did not realize that valout was giving the evaluated value which I should probably be using from now on.

Thank you for clarifying that for me!
User avatar
Eddy Alleman
Posts: 44
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 78
x 86
Contact:

Re: If a custom property has associative dimension, how would I get the value and not the dimension name

Unread post by Eddy Alleman »

you're welcome

We all made that mistake once, but when stepping up we use other "values" than numbers.

Happy coding
Post Reply