Custom Propery Name
Custom Propery Name
(OP)
I have hundreds of SolidWorks parts that require approximately 40 identical custom properties adding to each of them. I intend to write the values of these custom properties via a design table.
Does anybody know of an easier way to create the custom properties than to open each part and painstakingly type in each one on each part.
P.S. i have very little API experience but would be glad of a little nudge into it.
Thanking you in anticipation.
Lucas
ON engineering.
Does anybody know of an easier way to create the custom properties than to open each part and painstakingly type in each one on each part.
P.S. i have very little API experience but would be glad of a little nudge into it.
Thanking you in anticipation.
Lucas
ON engineering.






RE: Custom Propery Name
Under SolidWorks API Tutorials click Macros/Examples then see Example 7. Then write yourself a Visual Basic 6 program to link the data you type in and SolidWorks.
Also check out http://solidworktip.tripod.com/api/macro_basics.htm#tip3 this is another good source for Custom Properties Tutorial.
There are several sites on the Internet. Whatever you learn about Visual Basic 6, you will use for other ideas.
RE: Custom Propery Name
Custom File Properties - This VB 5.0 program simplifies the task of entering a standard set of custom properties for your models. It will allow you to create or modify a standard set custom properties for a the active SolidWorks document. This program is easily customizable to a users specific needs using VB5.0 or VB 6.0. WE ahve used to with success.
This is found under subscription support, model library, API, general utilities. If you do not have subscription support I could send it to you.
BBJT CSWP
RE: Custom Propery Name
To use this, just record a new macro, do nothing and stop recording. Save the macro then edit it and replace with this code. Then, just run the macro when you have a file opened and run it.
Option Explicit
Dim swApp As Object
Dim Part As Object
Const swCustomInfoUnknown = 0
Const swCustomInfoText = 30
Const swCustomInfoDate = 64
Const swCustomInfoNumber = 3
Const swCustomInfoYesOrNo = 11
Sub main()
Dim sConfig As String
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
sConfig = "" 'not config specific
Part.AddCustomInfo3 sConfig, "description", swCustomInfoText, ""
Part.AddCustomInfo3 sConfig, "material", swCustomInfoText, ""
Part.AddCustomInfo3 sConfig, "spec1", swCustomInfoText, ""
Part.AddCustomInfo3 sConfig, "spec2", swCustomInfoText, ""
Part.AddCustomInfo3 sConfig, "weight", swCustomInfoNumber, 0
Set Part = Nothing
Set swApp = Nothing
End Sub
Hope this helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Custom Propery Name
Crashj Johnson
RE: Custom Propery Name
Thanks for the code. I'm a rookie to VB and this worked great. I edited the code to our custom pros and it works great.
One question: I had someone at a Solidworks reseller (in the past) write a VB program that was like an editor. I hit the .exe and an editor comes up on the screen. It is set up with all the custom props I want to add to the open file. It has an area next to each one to fill in the "values" of the custom props. Then I just hit APPLY and the props AND their values get added to the open Solidworks file.
How is this set up? I think the code you attached just adds the prop names, but w/o the values, right?
I'm reading up and learning VB as we speak. It's all new to me so bear with any stupid questions.
Thx
Stormrider
RE: Custom Propery Name
Go to www.nhcad.com web site and look at Joe's Custom Properties example.
Bradley
RE: Custom Propery Name
Yes, that code just added the names. Those commands can also add the value, using the last parameter. If you are just learning VB, you should check out the sample that Bradley pointed out. With a little practice with VB, you can create a form to your liking. Then, simply use the SW API above to populate the custom properties. You will also have to include a call to Part.CustomInfo2 to get any information that may already be there. You will also have to take into account different configurations, if that is something you use.
I think that I may be making it sound harder than it is. Again, check out the nhcad link for a good sample.
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.