Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Macro - Part.GetTitle in Drawings

Status
Not open for further replies.

dedevo

Mechanical
Joined
Dec 3, 2010
Messages
54
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top