Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Settings macro

Status
Not open for further replies.

CADGemini

Mechanical
May 12, 2004
481
I'm looking for a way to create a macro that will set all the "document settings" I have in my template to an old company drawing. I find myself setting the document font and size for each old drawing that I have. This becomes very tedious. I did find an excel-based macro on the internet that will set most of the document settings but not the font style and size. And the macro is password protected so I cannot edit or manipulate it. Does anyone have any ideas on creating a simple macro to set font style and size that I specify in my templates? I am new to VB so please be gentle.

Thanks,

Jon (a.k.a. jksolid)

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
Replies continue below

Recommended for you

Jon,
For SolidWorks 2004 Check out “Copy Option Wizard”
Click windows Start button, Programs, SolidWorks, SolidWorks Tools, then Copy Option Wizard.

For SolidWorks 2005 Check out “Copy settings Wizard”
Click windows Start button, Programs, SolidWorks, SolidWorks Tools, then Copy “Copy Settings Wizard”


Bradley
 
Is this the macro that you tried?

It was created by Stefan Berlitz and seems VERY complete. It does not appear to be updated for 2005 yet, but it should work (perhaps missing a couple new or changed 2005 options).

It is not password protected, but all API remarks are in German (I think).
 
Thank you Bradley and Arlin for your prompt responses.

Bradley,

I completly forgot about that program, thanks for the reminder. But do you know if there is a way to imbed the Copy Option Wizard into a menu item, Like the Solidworks Explorer is in the "Tools" menu?

Arlin,

That is the macro I did try but it does not apply text style and text size to the drawing. It mentions a few other things that it does not update also.

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
Why do you need a macro to do this???

Your Document settings are saved in the templates you use on a daily basis. If you open a new file up using the template that you normally use and then change the settings in Tools\Options\Document Properties - Then save it off either as the same name or as a new name (Save it as an *.xxxdot file) then the next time you start a new file you have the template with all your settings in it. No needs to run a macro.

Regards,

Scott Baugh, CSWP [pc2]

faq731-376
 
Scott,

The reason I need a macro to do this is that we have old templates that were used before I got here. I then created new templates that have logic to them(unlike the old ones). Now we are trying to update the old files that used the old templates and trying to update all those options for each drawing seems quite unnecessary. Especailly when we have 20 or more drawings to do at a time.


A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
Scott,

Sometimes it is the simplest things that we seem to forget.

That will save me lots of time.

Thanks again!

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
If you still need such a macro I can help ya out.
 
AAMOROSO,

If you don't mind I would like to see what kind of macro you have to do this. I think it would benefit the other users here that are unfamiliar with SW.

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
Code:
Sub main()

Dim Now         As Boolean
Dim StdFont     As Object


    
    
Set swApp = Application.SldWorks                    ' Attach to SolidWorks
Set Document = swApp.ActiveDoc                      ' Get active document
 
        If Not Document Is Nothing Then                 ' A Document is open
            FileTyp = Document.GetType                  ' Get document type
            If FileTyp = swDocDRAWING Then              ' If it is a drawing continue else skip ahead
                SheetNames = Document.GetSheetNames
                                
'*********** Set new defaults for Font settings on all annotation types **************************

           
            
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingDetailTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingDetailTextFormat, StdFont)
                              
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingBalloonTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingBalloonTextFormat, StdFont)
                            
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingDimensionTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingDimensionTextFormat, StdFont)
                              
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingNoteTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingNoteTextFormat, StdFont)
                
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingGeneralTableTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingGeneralTableTextFormat, StdFont)
                              
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingSectionTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingSectionTextFormat, StdFont)
                           
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingSurfaceFinishTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingSurfaceFinishTextFormat, StdFont)
                            
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingWeldSymbolTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingWeldSymbolTextFormat, StdFont)
                
                Set StdFont = Document.GetUserPreferenceTextFormat(swDetailingViewArrowTextFormat)
                    StdFont.TypeFaceName = "Helvetica"
                    StdFont.CharHeightInPts = "10"
                    Now = Document.SetUserPreferenceTextFormat(swDetailingViewArrowTextFormat, StdFont)


End Sub
[code]
 
aamoroso,

Thanks for the code. I will try it out and let you know how it works for us here.

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
ooops, missing a couple of end ifs before End Sub, sorry bout that, also I should mention this will set all your defaults to Helvetica Font, 10pt
 
aamoroso,

What are the end ifs statements?

I could not figure them out.

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
Notice near the begining of the code it says " If Not Document Is Nothing Then ' A Document is open"

Well if there is no document open it jumps to find an "End IF" so put one at the bottom on the line above "END SUB"

Back to the top notice " If FileTyp = swDocDRAWING Then " well if file type is not a drawing it will look for the end of that if also, so again above the first end if put another "End if"


the bottom should look like this.

End if
End if
End sub

Let me know if that dont work
 
Works great now!

Thanks for your help.

I might add a user interface to it so that you can select a font that will globalize each setting.

Might take me awhile cuz I am not so good with writing macros as you probably know.

A man should look for what is, and not for what he thinks should be. -Albert Einstein

A person who never made a mistake never tried anything new. -Albert Einstein
 
yeah, i use the same one with the added features of setting Arrow ht, arrow wt, and several other settings we have recently chaged in our company format. Just remember that only sets the defaults, it wont change existing notes that are not set as defualt font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor