Missing enumartion for equation

Programming and macros
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Missing enumartion for equation

Unread post by Hansjoerg »

Hi all,

i try do add some properties to a Weldment cutlist, i use this example as referenz. Add and Get Custom Properties Example (VBA) - 2021 - SOLIDWORKS API Help

For "normal" properties it works fine, but i must also add an property that includes an equation.

The enumeration for the CustomeInfoType offers no member for an equation. swCustomInfoType_e Enumeration - 2021 - SOLIDWORKS API Help
I have trieded it with the member swcustomInfoUnkown but with this choise my property is not added to the cutlist

If I display the value of the type of an existing property with equation I get the result "30" which corresponds to the type "Text".

I have found the same question in the cadoverflow forum, if i understood in the right way the problem cound not reproduce there

I have report the problem to the DSS api support team. I hope somebody is working between the years. Or did somebody from the forum here knows a solution?
by Hansjoerg » Thu Jan 12, 2023 7:27 am
I have found a solution!

If you use the oldest version "Add" instead of the newest method "Add3" it works!

The difference is due to the different declaration of the variables for fieldtype.
With "Add3" it is in VBA a variable of the type "Long" or selectable over an enumeration.
With "Add" it is in VBA a variable of the type "String" where I can enter what I want.

A first test with the old method was positive for me!
Go to full post
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
josh
Posts: 238
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 10
x 18
x 417

Re: Missing enumartion for equation

Unread post by josh »

If I'm reading all this correctly, the type "equation" does not actually exist.

You read the type of an equation with API and you got "30"
At the cadoveflow link, the OP used "30" to create their property, and they ended up with an Equation type.
This should clue you in that the equation type does not exist. Whether or not you end up with an equation depends on the content of the text.
Just use "30".
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Re: Missing enumartion for equation

Unread post by Hansjoerg »

I have adapted my macro and inserted the value 30 instead of the enumeration. But unfortunately it did not lead to the hoped for result.
The "formula" I specify as equation is displayed to me without calculation as result.
2022-12-29 08_46_17-Zuschnittslisten-Eigenschaften.png
Is it because of the way the formula is written?
2022-12-29 09_15_56-Microsoft Visual Basic for Applications - Pimp_Cutlist - [Pimp_Cutlist1 (Code)].png
In the meantime I have also received a feedback from the API support:
Currently SOLIDWORKS APIs lacking this functionality.
We have already got following enhancement request for this requirement in our SPR database:
SPR 1197201 : Extend ICustomPropertyManager APIs to support adding custom property of equation type.
I have added this SPR to your service request and you will be automatically notified when it gets fixed.
There isn't any workaround method available for this functionality.
Is there another way to output the weight in pounds instead of kilograms?
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
mattpeneguy
Posts: 1370
Joined: Tue Mar 09, 2021 11:14 am
Answers: 4
x 2475
x 1866

Re: Missing enumartion for equation

Unread post by mattpeneguy »

There's not a clean way I can come up with. You can use a Design Table to do the math and get that output into a Custom Property. Dirty, but it works.
I attached a file with it done with configuration specific properties.
Attachments
Part1.SLDPRT
(96.85 KiB) Downloaded 24 times
User avatar
gupta9665
Posts: 357
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 376
x 412

Re: Missing enumartion for equation

Unread post by gupta9665 »

Hansjoerg wrote: Thu Dec 29, 2022 3:41 am
Is it because of the way the formula is written?
You can not have the values multiplied in the custom properties but only in equations. So you need to add an equation and link the property with that. Here is an old post on same topic https://gupta9665.wordpress.com/2011/06 ... olidworks/
Deepak Gupta
SOLIDWORKS Consultant/Blogger
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Re: Missing enumartion for equation

Unread post by Hansjoerg »

gupta9665 wrote: Thu Dec 29, 2022 10:58 am You can not have the values multiplied in the custom properties.....

This SOLIDWORKS Tech Blog describes that it is possible.

But I will still try to apply your suggested solution tomorrow.
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
gupta9665
Posts: 357
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 376
x 412

Re: Missing enumartion for equation

Unread post by gupta9665 »

Hansjoerg wrote: Thu Dec 29, 2022 4:54 pm This SOLIDWORKS Tech Blog describes that it is possible.

But I will still try to apply your suggested solution tomorrow.
Yes forgot that 2021 and onwards has this option added. Let me check that again.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
User avatar
josh
Posts: 238
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 10
x 18
x 417

Re: Missing enumartion for equation

Unread post by josh »

Well, this is pretty interesting. I finally took a minute to try it out for myself, and also it looks like some more detail has been posted over on the other referenced forum.

It looks like the other poster was unintentionally ending up with an equation type when his input value was interpretable as an equation. However, when he installed the English version instead of the French version, this behavior went away. I tried in my machine (English install of course) and ended up with the same result - Equation type is not possible to create. Just for fun, I tried every value from -2000 to +2000 for the Type argument. Only 30 and (interestingly) 11 successfully created a custom property when the value contained anything non-numeric. 3 and 5 successfully created a property when I changed the value to numeric. It looks like you're stuck until they fix the API.
User avatar
gupta9665
Posts: 357
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 376
x 412

Re: Missing enumartion for equation

Unread post by gupta9665 »

Well it's reported under SPR #1197201. Kindly vote for it.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Re: Missing enumartion for equation

Unread post by Hansjoerg »

gupta9665 wrote: Sat Dec 31, 2022 1:04 am Well it's reported under SPR #1197201. Kindly vote for it.
Done!
Thanks to all for support!
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Re: Missing enumartion for equation

Unread post by Hansjoerg »

I have found a solution!

If you use the oldest version "Add" instead of the newest method "Add3" it works!

The difference is due to the different declaration of the variables for fieldtype.
With "Add3" it is in VBA a variable of the type "Long" or selectable over an enumeration.
With "Add" it is in VBA a variable of the type "String" where I can enter what I want.

A first test with the old method was positive for me!
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
josh
Posts: 238
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 10
x 18
x 417

Re: Missing enumartion for equation

Unread post by josh »

Gold star for you sir! Way to dig back through the archives! You may want to inform whoever told you there is no workaround and rub it in their face... :lol:
User avatar
Hansjoerg
Posts: 106
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 55

Re: Missing enumartion for equation

Unread post by Hansjoerg »

In case anyone can help, I'll post my solution and a demo file here. I have tested the workaround with SWX 2021 SP5.1.
It is important to adjust the string for "equation" to the respective language setting of the menus.
2023-01-31 11_18_59-Microsoft Visual Basic for Applications - AddCutlistProperty - [AddCutlistProper.png
After running the macro, the properties of the end cap contain the equation
2023-01-31 11_16_38-Cut-List Properties.png
Attachments
AddCutlistProperty.swp
(53 KiB) Downloaded 44 times
Demo_File_Add_Equation.SLDPRT
(76 KiB) Downloaded 45 times
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
Post Reply