How to add configuration-specific Cut List properties?

Programming and macros
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

How to add configuration-specific Cut List properties?

Unread post by laukejas »

I want to add configuration-specific Cut-List item properties, so they would appear like this:
image.png
By default, accessing ICustomPropertyManager from Feature won't allow me to specify configuration name:

Code: Select all

Set swCustPropMgr = selectedFeature.CustomPropertyManager(activeConfig.Name)
swCustPropMgr.Add3 "SW-Part Number", swCustomInfoText, number, swCustomPropertyReplaceValue
The above doesn't work - ICustomPropertyManager doesn't support specifying configuration name as a parameter when accessed from IFeature, like it would when accessing it from IModelDocExtension (link to docs)

So instead I tried to access ICustomPropertyManager from config cut list items:

Code: Select all

vcutlistItems = activeConfig.GetCutListItems()

For Each vcutlistItem In vcutlistItems
    Set swCustPropMgr = selectedItem.CustomPropertyManager()
    swCustPropMgr.Add3 "SW-Part Number", swCustomInfoText, number, swCustomPropertyReplaceValue
Next
Documentation is a bit obscure here, it feels like this is a weird corner of SW API. ICutListItem only has a single public member, CustomPropertyManager, so I assume the only intended reason for getting instance of CustomPropertyManager this way is to do exactly what I'm trying to do - but it doesn't work with the above code sample, property is still written as "All configs".

So what is the correct way to create a configuration-specific cut-list property via API?
User avatar
gupta9665
Posts: 410
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 433
x 449

Re: How to add configuration-specific Cut List properties?

Unread post by gupta9665 »

I believe this is not yet supported thru API. Reach out to your VAR, and ask them to verify.

Here is a similar post https://r1132100503382-eu1-3dswym.3dexp ... mDbQAjb8mQ
Deepak Gupta
SOLIDWORKS Consultant/Blogger
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

gupta9665 wrote: Mon Oct 07, 2024 11:36 am I believe this is not yet supported thru API. Reach out to your VAR, and ask them to verify.

Here is a similar post https://r1132100503382-eu1-3dswym.3dexp ... mDbQAjb8mQ
Thanks, I did it, and we confirmed it's a bug, got it through to SW R&D. It's now registered as BR10000388022. That being said, I don't think R&D will consider this important enough to fix anytime soon, there are far more serious bugs that haven't received any attention for many years now.

So what can be done to work around this bug, set these cut-list properties as "this configuration" via API in some other, maybe some indirect way? Any suggestions?
User avatar
Eddy Alleman
Posts: 50
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 80
x 89
Contact:

Re: How to add configuration-specific Cut List properties?

Unread post by Eddy Alleman »

workaround: you can activate the configuration you want and then get the custom property for the active configuration.

This has botthered me too for a long time so i filed a SR

Last year i got a message from Solidworks that the following is added in SOLIDWORKS 2024 SP2:

🔹 SR# 1-23751953419
Description: SOLIDWORKS API: Enhancement - New method to obtain configuration-specific Cut List properties.

I haven't tested it out myself yet, so please let us know your findings!

Eddy
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

Eddy Alleman wrote: Wed Oct 09, 2024 10:15 am workaround: you can activate the configuration you want and then get the custom property for the active configuration.

This has botthered me too for a long time so i filed a SR

Last year i got a message from Solidworks that the following is added in SOLIDWORKS 2024 SP2:

🔹 SR# 1-23751953419
Description: SOLIDWORKS API: Enhancement - New method to obtain configuration-specific Cut List properties.

I haven't tested it out myself yet, so please let us know your findings!

Eddy
Thanks, but I think you misunderstood what I meant: reading properties works fine (with your method), but I am trying to write properties as "this configuration". Meaning the values would be different in different configurations.
User avatar
Eddy Alleman
Posts: 50
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 80
x 89
Contact:

Re: How to add configuration-specific Cut List properties?

Unread post by Eddy Alleman »

OK, I know I have tested with this some years ago and i filed an enhancement request several times. Even using the WINAPI it is not possible to mimic the clicking on the icon on the right.

I did have a look into my code from then and found this remark:

//IMPORTANT REMARK for SolidWorks 2021 cutlist custom properties
//When using different configurations the cut list item bodies custom properties can be overwritten behind the scene
//Therefor don't use different configurations if you want the cutlist body custom properties to remain the same
//this is also the case when manual changing properties ( even if we click the this config only button) and also via API
//solution : save the multibody part as a new part and create BOM's there.

Since then i use the rule of thumb: "Don't use cutlists and configurations at the same time"

So I think you are out of luck
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

Eddy Alleman wrote: Thu Oct 10, 2024 4:36 am OK, I know I have tested with this some years ago and i filed an enhancement request several times. Even using the WINAPI it is not possible to mimic the clicking on the icon on the right.

I did have a look into my code from then and found this remark:

//IMPORTANT REMARK for SolidWorks 2021 cutlist custom properties
//When using different configurations the cut list item bodies custom properties can be overwritten behind the scene
//Therefor don't use different configurations if you want the cutlist body custom properties to remain the same
//this is also the case when manual changing properties ( even if we click the this config only button) and also via API
//solution : save the multibody part as a new part and create BOM's there.

Since then i use the rule of thumb: "Don't use cutlists and configurations at the same time"

So I think you are out of luck
Damn, you even tried WINAPI. Now that's dedication :D

I am aware of that bug, but it was fixed sometime after 2021, not sure exactly when. But in 2024, it works fine, if you add configuration-specific cut-list properties, they stay correct, nothing gets overwritten anymore. So it works if you do it manually. But still not via API, which is what I'm trying to do.
User avatar
Eddy Alleman
Posts: 50
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 80
x 89
Contact:

Re: How to add configuration-specific Cut List properties?

Unread post by Eddy Alleman »

Great to hear you're on 2024! 😄 Thanks for confirming that the bug is gone!

I was checking out the new features in SolidWorks 2024 API, and I came across :

A cut list (see: ICutListItem::CustomPropertyManager and IConfiguration::GetCutListItems)
An assembly component (see: IComponent2::CustomPropertyManager)
Here’s the link for the full rundown:
https://help.solidworks.com/2024/englis ... ksapi.html

While looking into Configuration::GetCutListItems, I found an example that shows how to use it:

Code: Select all

Set config = swModel.GetConfigurationByName(vConfigName)
vcutlistItems = config.GetCutListItems()
Basically, you first grab the configuration, then use GetCutListItems() to access the cut list items. After that, you can get it's CustomPropertyManager, which has methods like add3, delete2, get6, and set2.

Did you try the Set2?
In ancient times we had to delete before adding again.
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

Eddy Alleman wrote: Thu Oct 10, 2024 9:11 am Great to hear you're on 2024! 😄 Thanks for confirming that the bug is gone!

I was checking out the new features in SolidWorks 2024 API, and I came across :

A cut list (see: ICutListItem::CustomPropertyManager and IConfiguration::GetCutListItems)
An assembly component (see: IComponent2::CustomPropertyManager)
Here’s the link for the full rundown:
https://help.solidworks.com/2024/englis ... ksapi.html

While looking into Configuration::GetCutListItems, I found an example that shows how to use it:

Code: Select all

Set config = swModel.GetConfigurationByName(vConfigName)
vcutlistItems = config.GetCutListItems()
Basically, you first grab the configuration, then use GetCutListItems() to access the cut list items. After that, you can get it's CustomPropertyManager, which has methods like add3, delete2, get6, and set2.

Did you try the Set2?
In ancient times we had to delete before adding again.
Oh, damn, I hadn't realized that this API call was added on 2024, I thought it was some time earlier. But yeah, I already tried it, and unfortunately Add3 still adds property as "all configurations" instead of "this configuration". With my VAR, we reported this to the SW R&D, and they acknowledged that this is a bug (it's the BR I mentioned in this topic a few posts ago, here is the link: BR10000388022

But this is actually good news. If this API was added in 2024, then it's means this is not some ancient bug since time immemorial, it's something that they missed very recently. So there is a good chance that with this BR, it will get fixed. You restored my hope :lol:
User avatar
Eddy Alleman
Posts: 50
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 80
x 89
Contact:

Re: How to add configuration-specific Cut List properties?

Unread post by Eddy Alleman »

it's something that they missed very recently.
Damn they add code for configuration specific properties and set it for all configurations... One wonders if they test it...


I wanted to upvote the BR, but seems this is only for your eyes...
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

Eddy Alleman wrote: Thu Oct 10, 2024 10:41 am Damn they add code for configuration specific properties and set it for all configurations... One wonders if they test it...


I wanted to upvote the BR, but seems this is only for your eyes...
Yeah, there seems to be quite a lot of new features in 2024 that didn't receive proper testing. Don't worry about BR upvote, I don't think that is possible anyway, at least I don't see how :D
User avatar
Eddy Alleman
Posts: 50
Joined: Thu Apr 01, 2021 10:32 am
Answers: 8
Location: Belgium
x 80
x 89
Contact:

Re: How to add configuration-specific Cut List properties?

Unread post by Eddy Alleman »

Don't worry about BR upvote, I don't think that is possible anyway, at least I don't see how :D
in that case i will add your findings to my SR. :D

happy coding!
laukejas
Posts: 199
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 43
x 113

Re: How to add configuration-specific Cut List properties?

Unread post by laukejas »

Eddy Alleman wrote: Fri Oct 11, 2024 7:29 am in that case i will add your findings to my SR. :D

happy coding!
Please let me know how it goes!
Post Reply