macro system and document settings

Discussion in 'SolidWorks' started by Gerard Knoop, Apr 20, 2004.

  1. Gerard  Knoop

    Gerard Knoop Guest

    Hi All!

    I'm looking for a way to set the system and document settings to a standard
    preset.
    Is this possible to do this with a macro and (even better) do you have an
    example?
    (I don't want to use a template!)

    Regards,
    Gerard
     
    Gerard Knoop, Apr 20, 2004
    #1
  2. Gerard  Knoop

    Seth Renigar Guest

    If I understand you correctly, you are wanting to set the document settings
    every time you start a new document. The system settings don't need to be
    changed every document cause they don't change document to document.

    If this is the case, you can download "Copy Document Options" from
    http://swtools.cad.de/download.htm . This is simply an Excel document. It
    copies all of the settings from the active document. You then bring another
    document to the active window and apply these settings to it.

    To get it to keep a "standard" document setting that you like, simply setup
    a documents like you want it, copy the options using the appropriate tab of
    the "Copy Document Options", and save it to a new Excel filename. Then, in
    future documents, all you have to do is open this Excel file and press a
    button to change all of the settings to the settings saved in the Excel
    file.

    It will also copy and apply system options as well. I could see how using
    this to apply the same system settings from workstation to workstation could
    be useful. But using this option on the same workstation would be
    redundant.

    Hope this is what you were wanting...

    I would like to know why you are against using a template though...
     
    Seth Renigar, Apr 20, 2004
    #2
  3. That idea would work well - however, if you do decide you want a stand-alone
    macro, it is fairly simple to do.

    You use the SolidWorks object (SldWorks.SldWorks) to access system level
    properties and the ModelDoc2 object (SldWorks.ModelDoc2) to access document
    level properties.

    Assuming you have the target document open, just call:

    Dim swApp as SldWorks.SldWorks
    Set swapp=Application.SldWorks

    Dim swModel as SldWorks.ModelDoc2
    Set swModel=swApp.ActiveDoc

    swApp.SetUserPreferenceToggle or .SetUserPreferenceString, or
    ..SetUserPreferenceInteger, or .SetUserPreferenceDouble

    You can find the appropriate setting by looking them up in API help.

    The same set of calls exists for swModel
     
    Evan T. Basalik, Apr 20, 2004
    #3
  4. Gerard  Knoop

    Gerard Knoop Guest

    Thanks for your help!
    I will have a look to both solutions.
    Gerard Knoop
     
    Gerard Knoop, Apr 21, 2004
    #4
  5. Gerard  Knoop

    JJZ Guest

    Geachte heer Knoop,

    Ik vond deze link op het net.

    Misschien het proberen waard.

    http://solidworks.cad.de/mm_08.htm

    Met vriendelijke groet,

    Jan Jurjen Zwaard
    Zwaard Engineering Studio
     
    JJZ, Apr 27, 2004
    #5
  6. Gerard  Knoop

    TinMan Guest

    Here's a macro I wrote a couple years ago (so it's not very pretty but
    it gets the job done). It basically switches a drawing from inch -to-
    mm, or vice-versa depending on current units being used in drawing
    file. I did this because all our templates were inch at the time. It
    should give you something to start with and then you can change/add to
    it as needed.

    Ken

    '*********
    Dim swApp As Object
    Dim Part As Object
    Dim val1, val2, ok As Integer
    Dim msg1 As String

    'These definitions are consistent with type names defined in
    swconst.bas and swconst.h
    '*** swUserPreferenceToggle ***
    Const swDetailingLinearDimPrecision = 24
    Const swDetailingLinearTolPrecision = 25
    Const swDetailingAltLinearDimPrecision = 26
    Const swDetailingAltLinearTolPrecision = 27
    Const swDetailingDualDimensions = 43
    Const swDetailingCenterMarkShowLines = 46
    Const swDetailingBalloonsDisplayWithBentLeader = 143
    '*** swUserPreferenceIntegerValue ***
    Const swDetailingDualDimPosition = 14 'Right=1, Top=2
    Const swUnitsLinear = 47 ' Millimeters=0, Inches=3
    'Const swUnitsLinearDecimalDisplay = 48
    Const swUnitsLinearDecimalPlaces = 49
    '*** swUserPreferenceDoubleValue ***
    Const swDetailingCenterMarkSize = 12

    Sub UserOptions()
    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc

    val1 = Part.GetUserPreferenceIntegerValue(swUnitsLinear)

    ok = Part.SetUserPreferenceToggle(swDetailingCenterMarkShowLines,
    False)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingDualDimPosition, 1)
    ok = Part.SetUserPreferenceToggle(swDetailingBalloonsDisplayWithBentLeader,
    False)

    If (val1 = 3) Then
    'Set to Metric
    ok = Part.SetUserPreferenceIntegerValue(swUnitsLinear, 0)
    ok = Part.SetUserPreferenceToggle(swDetailingDualDimensions, True)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingLinearDimPrecision,
    2)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingLinearTolPrecision,
    2)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingAltLinearDimPrecision,
    3)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingAltLinearTolPrecision,
    3)
    swApp.SendMsgToUser "Conversion to Metric made successfully"
    Else
    'Set to Inch
    ok = Part.SetUserPreferenceIntegerValue(swUnitsLinear, 3)
    ok = Part.SetUserPreferenceToggle(swDetailingDualDimensions, False)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingLinearDimPrecision,
    3)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingLinearTolPrecision,
    3)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingAltLinearDimPrecision,
    2)
    ok = Part.SetUserPreferenceIntegerValue(swDetailingAltLinearTolPrecision,
    2)
    swApp.SendMsgToUser "Conversion to Imperial made successfully"
    End If

    End Sub
     
    TinMan, May 3, 2004
    #6
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.