simple macro help

Discussion in 'SolidWorks' started by Knotfreak, Aug 26, 2005.

  1. Knotfreak

    Knotfreak Guest

    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
     
    Knotfreak, Aug 26, 2005
    #1
  2. Knotfreak

    TOP Guest

    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)
     
    TOP, Aug 26, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.