Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom properties

Status
Not open for further replies.

Immow

Industrial
May 13, 2011
6
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.
 
Replies continue below

Recommended for you

You might be able to do this with a macro feature (a macro that is designated to run each time the file is rebuilt). Unfortunately I have never worked with one before.

The following link has some code for creating a macro feature:

Eric
 
IswApp.IActiveDoc2
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
 
Sorry it's supposed to be:

swModelDoc = IswApp.IActiveDoc2
Dim sFileTitle as String = swModelDoc.GetTitle

James Spisich
Design Engineer, CSWP
 
This is easily done with a line of VBA code embedded in an equation. Search here for vba in equations or check my (Josh Brady) presentation from SWW '11 on the SW website (if it's still available) for details. Sorry, have to go to bed now. It's midnight here.

-handleman, CSWP (The new, easy test)
 
Dear Jspisich,

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
 
Similar issue---

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor