×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Custom properties

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.

RE: Custom properties

Can you use the Value/Text Expression in the custom properties info instead of the file name?

Chris
SolidWorks 11
ctopher's home
SolidWorks Legion

RE: Custom properties

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:
https://forum.solidworks.com/thread/45193

Eric

RE: Custom properties

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

RE: Custom properties

Sorry it's supposed to be:

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

James Spisich
Design Engineer, CSWP

RE: Custom properties

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)

RE: Custom properties

(OP)
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
 

RE: Custom properties

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources