macro system and document settings

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
Reply to
Gerard Knoop
Loading thread data ...
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
formatting link
. 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...
Reply to
Seth Renigar
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
Reply to
Evan T. Basalik
Thanks for your help! I will have a look to both solutions. Gerard Knoop
"Evan T. Basalik" schreef in bericht news:mdghc.58714$ snipped-for-privacy@bignews3.bellsouth.net...
Reply to
Gerard Knoop
Geachte heer Knoop,
Ik vond deze link op het net.
Misschien het proberen waard.
formatting link
Met vriendelijke groet,
Jan Jurjen Zwaard Zwaard Engineering Studio
Reply to
JJZ
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
Reply to
TinMan

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.