×
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

Macro - Part.GetTitle in Drawings

Macro - Part.GetTitle in Drawings

Macro - Part.GetTitle in Drawings

(OP)
IModelDoc2.GetTitle
When issued in drawings, it returns the sheet info:
ie.  CW201AM - Sheet1

I want to rip just the filename:
CW201AM.slddrw  ->  CW201AM

I am making a macro to SaveAs PDF and don't want to have to go back through later and strip out all of the "useless" info.

I was thinking of writing some code that would interpret where the first space is, but I don't like that idea incase my drawings do have a space in the filename.
Is there another function I can call?

Devon Murray, EIT [Mechanical]
Solidworks 2011 SP 2.0

RE: Macro - Part.GetTitle in Drawings

Add Microsoft Scripting Runtime (C:\Windows\SysWOW64\scrrun.dll on my box) to your macro references.  Then include something like the following in your macro.

CODE

Dim fs As New Scripting.FileSystemObject
Dim name As String
name = fs.GetBaseName(document.GetPathName)

where document is your object of type IModelDoc2.  The GetBaseName method extracts the file name (without extension) from the full path returned by IModelDoc2.GetPathName.

Eric

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