API: Editing Custom Properties Share

Good evening

 

Can we modify custom properties via a macro?

I have 4 properties that I want to change.

 

Thanks in advance,

Gautier

Good evening, yes it's possible,

 

To recover your property (example with my SolidWorks property code):

 

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

 

And to modify it (update the CODE property with the NewCode variable):

retval = SWmoddoc.AddCustomInfo3("", "CODE", 30, NewCode)
SWmoddoc.CustomInfo("CODE") = NewCode

1 Like

Thank you for your answer.

Is the reverse possible?

 

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

Yes, I just edited my answer, the instruction is in 2 lines ;-)

1 Like

What type of Retval is there?

And do I need to add a dll to have access to the swmoddoc function?

Good evening

I see that you are under an Axemble maintenance contract. If you also have a subscription for MyCADTools tools, BatchProperties is a perfect fit!

Yes we have mycadtools, but unless I'm mistaken, Batch Properties doesn't handle different property assignments between files. To put it simply, I want (for example) the reference of my part to be put in the reference property.

 

Otherwise I'm moving forward but I still don't have the right result.

I put my code. I put the top line and the bottom line. basically I want to edit the "Description" property when I open a step and save it in part.

Here's my code:

swApp1.SetUserPreferenceIntegerValue swSaveAssemblyAsPartOptions, swSaveAsmAsPart_ExteriorFaces

Set swmoddoc = swApp1.ActiveDoc
If OTB_OUI_COMMERCE. Enabled = True Then
    retval = swmoddoc. AddCustomInfo3("", "Description", 30, descrip)
    swmoddoc. CustomInfo("Description") = descrip
End If

swModelDocExt1.SAVEAS NewFilePath, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings

 

1 Like
Retval is a Boolean
1 Like
What's the problem? Is there a mistake?

Hello

 

It's okay, I managed to do what I wanted. FYI, I had to reopen the room, update the properties, save and close.

 

Thank you for your help.

Gautier

1 Like