simple macro help

Aug 26, 2005 1 Replies

I've used the macro feature a couple of times before but never got into programming with code.



I have created a macro that rotates the part to an isometric view, zooms it to fit the screen and saves it to a specific location.


'
****************************************************************************
** ' C:\DOCUME~1\lucas\LOCALS~1\Temp\swx1772\Macro1.swb - macro recorded on
08/26/05 by lucas '
****************************************************************************
** Dim swApp As Object Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Sub main()

Set swApp = Application.SldWorks



Set Part = swApp.ActiveDoc Part.ShowNamedView2 "*Isometric", 7 Part.ViewZoomtofit2 Part.SaveAs2 "E:\Lucas\Seradex Items\Part Pictures\11115.JPG", 0, True, False End Sub


As you can see, the part is always saved under the name "11115.JPG". I would like to change it so that the file name minus the ".SLDPRT" is used.



Can anyone help me out?



Thanks


This might be of some help:

'Get the full pathname of the document PName = Part.GetPathName()

'Strip off the path leaving the document name and extension ptrFname = InStrRev(PName, "\") + 1 FName = Mid(PName, ptrFname)

'Strip off the extension ptrFname = InStr(FName, ".") - 1 FName = Left(FName, ptrFname)

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required