Custom properties
Custom properties
(OP)
Hello, my old thread got closed and we are still looking for a suitable solution for our problem.
We are working on a part temaplte.
We use the custom properties: Filename -> $PRP:"SW-File Name" to get the filename of the document.
Our filename contains partnumber and a description, we would like to separate those for BOM and Drawings.
Example: [partnumber] desciption.SLDPRT
Is it possible to strip the first 10 symbols leaving only the "Desciption" (partnumber is predefined length) and vice versa to leave the "partnumber"?
These new values should populate the custom properties
PartNu & Name
I got this kinda to work with a Design table. Problem is the design table does not update when saving the part template under a new name, only when you enter the design table does the value update. CTRL Q or CTRL B have no effect.
We are working on a part temaplte.
We use the custom properties: Filename -> $PRP:"SW-File Name" to get the filename of the document.
Our filename contains partnumber and a description, we would like to separate those for BOM and Drawings.
Example: [partnumber] desciption.SLDPRT
Is it possible to strip the first 10 symbols leaving only the "Desciption" (partnumber is predefined length) and vice versa to leave the "partnumber"?
These new values should populate the custom properties
PartNu & Name
I got this kinda to work with a Design table. Problem is the design table does not update when saving the part template under a new name, only when you enter the design table does the value update. CTRL Q or CTRL B have no effect.






RE: Custom properties
Chris
SolidWorks 11
ctopher's home
SolidWorks Legion
RE: Custom properties
The following link has some code for creating a macro feature:
https://forum.solidworks.com/thread/45193
Eric
RE: Custom properties
Dim sFileTitle as String = IswApp.GetTitle
Dim PartNu = Microsoft.VisualBasic.Left(sFileTitle, 10)
Dim sFileTitleLen as Integer = sFileTitle.Length - 10
Dim Description = Microsoft.VisualBasic.Right(sFileTitle, sFileTitleLen)
Something along those lines, then set them however you want with the other api to add or change a custom property.
James Spisich
Design Engineer, CSWP
RE: Custom properties
swModelDoc = IswApp.IActiveDoc2
Dim sFileTitle as String = swModelDoc.GetTitle
James Spisich
Design Engineer, CSWP
RE: Custom properties
-handleman, CSWP (The new, easy test)
RE: Custom properties
Thank you for your help and example code.
I tried to copy & past it at Equations, Global Variables but it gives a error.
Would you be so kind to make a example file or point out what i'm doing wrong.
Kind regards,
Koen
RE: Custom properties
We wanted the work order no and qty on all drawings. The easiest (only) way I could figure out how to do that was to write a "property update" macro which counted all the duplicate parts and assemblies and put the quantity, workorder no, and rev num in the part properties which then appeared in the drawing. The drawing templates have to be set up to do this, but that is the easy part.
Its pretty easy to strip whatever you want from whatever you want in a macro and trying to do it with equations or design tables just didn't work for us. We found that equations don't update reliably no matter what you do and design tables have other issues that I don't remember (we haven't used them for a few years for some very good reasons I don't remember).
I think you will find that writing a VBA program (macro) and running it as a last step for an assembly design is going to be the best, most reliable, and practical way to do this.
John