Issue with Add3 Method for Cutlist Custom Property

Hi,
Trust you are well.
I am using the Add3 method with swCustomPropertyReplaceValue flag for writing values to cut list custom properties by accessing CustomPropertyManager from the Features interface. The problem is that this method is unreliable, because it will sometimes fail to write/update values. I have been unable to find the root cause…

Also, the method always fails to create a new field in cut -list custom properties. The only workaround here seems to first create the field with no/garbage value.

Is there a more robust method to add and update cutlist customproperty. We are currently using Solidworks 2018 SP 5.0.

Thanks.

swCustomPropertyReplaceValue is used when you want to replace the value of an existing property. So if the property doesn’t exist, this option will not do anything.

You can set the codes to check if property exists then update the value (using swCustomPropertyReplaceValue) else add the property and the value (using swCustomPropertyOnlyIfNew). Unless you want the properties to remain in the order, you can also use swCustomPropertyDeleteAndAdd and this will take care of all the needs.

2 Likes

Thanks.
But from my limited experimentation the swCustomPropertyReplaceValue flag creates a new field if it is not already existing in assembly or part documents, the behavior is somewhat unpredictable for cut list properties, because yesterday i ran the code again on a different weldment part an it was able to create a new field in cutlist properties with the above flag.

I did a test on both configuration and cut list properties, and it seems to work. But based on my earlier experience it has not worked in all cases. So I had stopped using it unless I wanted to replace the existing property value.

And is there any specific reason you can not use the swCustomPropertyDeleteAndAdd method?

1 Like

Ok so it looks like a bug. I will try to use the new flag and check if its robust. Does the Deleteand Add flag also work when a new property is being added to the document

Yes swCustomPropertyDeleteAndAdd works in both cases.

1 Like

Still facing the same issue. I didnt describe the problem properly I think
… when add3 isnt working as intended given that:
a. the field isnt already existing in cutlist properties: the procedure will actually create a BLANK field… the field will be created but no value will be written
b. the field exists: in which case it will fail to update the value
the problem is solved by opening the part and manually writing (any garbage) value in these fields and then these fields will be populated as expected by add3 method during the next run
of course the problem is completely random and it occurs on some computers more frequently, so i havent been able to determine the exact cause
no problem with document level properties though, just cutlist properties atm

I’ll check for cut list but I’m sure it should work.

1 Like

i was able to test this in greater detail and have following observations to share…

  • cut list properties are being skipped till i manually open the cutlist properties table. post which the method behaves as expected
  • the value can be retrieved using get6 method, but it isnt visible in the cutlist properties table

further, we are automatically adding configurations to the weldment part using a macro… i dont know if that is an issue. the add3 is executed using a completely different procedure and there is no interaction with the procedure that generates configurations. pls let me know if you’d like to look at the macro

thanks.