Try these codes

 

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustProp As SldWorks.CustomPropertyManager
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swCustProp = swModel.Extension.CustomPropertyManager("") 'Add config name in the quotes if you want configuration specific property
    swCustProp.Add3 "Description", 30, "Test 123", 1 ' Change property name as needed
End Sub

Categories: API∕Macros

Comments
Last comment By: Jonathan Westcott   Tue, 16 Jan 2018 23:15:42 GMT
Re: Macro is changing custom properties in both files

Great, that was the bit I was missing.

 

Set swCustProp = swModel.Extension.CustomPropertyManager("")

 

Thanks all

By: Jonathan Westcott  Fri, 12 Jan 2018 17:55:25 GMT
Re: Macro is changing custom properties in both files

Sorry just realised I branched this in the wrong place from this from this thread.

API Write to custom properties to Custom tab and NOT Config Specific Properties

 

So I edited the macro discuss in a previous topic but I'm finding that it is updating the custom properties of the original and destination files. Is there a way to get it to ignore the original as I want those custom properties to remain after.

 

I've attached how far I have got so far.

 

I'm guessing that I either need to:

 

  1. deactivate the original file (or close)
  2. activate the destination file
  3. Then run the Set2 functions

 

In this case I guess it is best to put the Set2 functions into a sub routine then call them in the two save as conditions.

 

I just can't work out how to deactivate the original file to stop it being written to.

 

Just wondering if this is the the correct approach?

By: Jonathan Westcott  Fri, 12 Jan 2018 19:40:10 GMT
Re: Macro is changing custom properties in both files

Jon, try this one.

By: Deepak Gupta  Sat, 13 Jan 2018 08:10:49 GMT
Re: Macro is changing custom properties in both files

Thanks Deepak, this is great!

Been making a few modifications since with varying degrees of success but I guess this is good for learning.

This was a really good start.

Cheers for the help.

By: Jonathan Westcott  Tue, 16 Jan 2018 23:15:42 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.