×
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

Properties + math/text-formula

Properties + math/text-formula

Properties + math/text-formula

(OP)
Hello all,

Working with SW2009 (4.1)

I'm trying to get some math/text funtions in the properties of a part.

What I'm trying to achieve is the following:
-Name / Text / $PRP:"SW-File Name"
-Name2 / Text / $PRP:"SW-File Name" - "SomeText"

Example:
The file name is: "172-Cardoor-SomeText"
Name2 would then have to be "172-Cardoor"

Is there some way to achieve such thing? I know how this could be done with something like Excel or something ... but SW ≠ Excel from what I've heard :p

-Grz J.

RE: Properties + math/text-formula

You are right.  It is not particularly possible.  

There are a couple of possible ways to work around it, though.  You could use Excel functions inside a design table to evaluate text and drive properties.  However, the values would only update if you open the design table.

Another way would be to set up a template that contains a macro feature.  That would not be quite as simple or straightforward as a DT (and a very daunting task for a beginner), but the macro feature would update the custom property with every rebuild.

-handleman, CSWP (The new, easy test)

RE: Properties + math/text-formula

(OP)
Hmm, ye thought so allready.

I've done some VB about 8 years ago. Looking at some existing macro like Lenny's makes me dizzy :D. Too bad, I'll go find for some other solution I guess. Ty anyway :)

-J

RE: Properties + math/text-formula

Just out of curiousity, is the difficult part the writing of the VB macro or the integration in a template?

A dirty work-around could be opening and closing the design-table (record it with macro-recorder). Then u have ur macro... my knowledge ends there... now how to integrate it in a template... ?

RE: Properties + math/text-formula

(OP)
Handleman,

I read this reply of you (Give value to cus.prop. with equation.), which made me remind me of this thread :). I'm pretty confident that I can get my problem to work on that equation. However, it looks a bit too unstable ( /unsupportde ;p) for what I have to do. So I went on googling a bit etc. Now I pretty much now how to get it to work in VBA. The thing I have no knowledge about is how to get this to work "OnRebuild".

So my question now is if anyone could give me some directions on how to get this to work (perheps with an existing macro, so I can filter that part out of it)

 

RE: Properties + math/text-formula

(OP)
I actually thought of another way to solve this. I just make a macro with the text edit part and in the end I put in the Rebuild command. This is what I have so far and it seems to be working pretty nice. I just need to build in some more checks for the "SOMETEXT" string.

CODE

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim cpm As CustomPropertyManager

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set cpm = swModel.Extension.CustomPropertyManager("")
    
    Dim PartNo_ValOut As String
    Dim PartNo_Resolvedvalout As String
    Dim PartNo2 As String
    Dim boolstatus As Boolean
    
    cpm.Get2 "PartNo", PartNo_ValOut, PartNo_Resolvedvalout
    
    If StrComp(Left(Right(PartNo_Resolvedvalout, 4), 3), "REV") = 0 Then
        cpm.Delete "PartNo2"
        cpm.Add2 "PartNo2", swCustomInfoText, Left(PartNo_Resolvedvalout, Len(PartNo_Resolvedvalout) - 5)
    Else
        cpm.Add2 "PartNo2", swCustomInfoText, "!PARTNO ERROR!"
    End If
        
    boolstatus = swModel.EditRebuild3()
    
End Sub

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