Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Changing title block 1

Status
Not open for further replies.

dogarila

Mechanical
Oct 28, 2001
594
My company has recently changed the title block format.
I would like to use some of the old drawings and replace the
old title block with the new one without losing any information, and eventually automatize this process. I know how to do this in AutoCAD (Autolisp) but not in SolidWorks.

Andrew (Netshop21)
andrew@netshop21.com
 
Replies continue below

Recommended for you

Netshop21,

If you are using the File/Properties for parts and assemblies, and are linking notes to them in the drafting environment, you can do the following;

Create your new drafting template. When you save this file, make sure that you ALSO click on File/Save Sheet Format. Now when you go into your existing drawings, you will have to edit the properties of each sheet. When you do, there is a dialog box. In the middle of the dialog box, you will see "Sheet Format". In the pull down, make sure that it says "Custom". In the field below, make sure that is pointing to your new template file, which in this case is actually the sheet format that you saved earlier. Click Ok.

This should change your sheet background. Unless you are not using the File/Properties for the parts and assemblies. If you are not, then sorry. I can't help you.
Jim Smithie, Webmaster
Free CAD evaluation kits and comparisons
 
If you would like to automate it, use this code. This will change the title block for the active drawing. You will need to specifiy the new template (sTemplateName). This will carry over the drawing properties as well. If you have Custom Properties set for title block values, they should carry over, assuming that the new template is set up the same way.
Code:
'-----------------------------------------------
'  Swap Title Blocks
'-----------------------------------------------
Option Explicit

Dim swApp As Object
Dim Part As Object
Dim Sheet As Object
Sub Main()
    Dim sSheetName As String, paperSize As Long, templateIn As Long
    Dim scale1 As Double, scale2 As Double, firstAngle As Boolean
    Dim templateName As String, width As Double, height As Double
    Dim propertyViewName As String, ret1, ret2 As Boolean
    Dim sTemplatePath As String

    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set Sheet = Part.GetCurrentSheet

    'Get Current Properties
    ret1 = Sheet.GetProperties
    paperSize = ret1(0)
    templateIn = ret1(1)
    scale1 = ret1(2)
    scale2 = ret1(3)
    firstAngle = ret1(4)
    width = ret1(5)
    height = ret1(6)
    sSheetName = Sheet.GetName
    'Set New Template
    sTemplatePath = "E:\Program Files\SolidWorks\data\Title-A.slddrt"
    ret2 = Part.SetupSheet4(sSheetName, paperSize, templateIn, scale1, scale2, firstAngle, sTemplatePath, width, height, propertyViewName)
    If ret2 = False Then
        swApp.SendMsgToUser "Sheet Setup Failed"
    End If
    Set Sheet = Nothing
    Set Part = Nothing
    Set swApp = Nothing
    
End Sub
Hope this helps! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Thanx, dsi. It works. Unfortunately the notes in the new template which are linked to custom properties don't show up after the swap :( . I don't know what happened to them. What can I do? Do I have to re-set them manually?

Andrew
 
I did not think that the Custom Properties were tied to the title block. I just performed this quick test:
1. Create a new drawing with Title1.slddrt
2. Add a custom property to the drawing
3. Save document
4. Run the program to switch to Title2.slddrt
The custom property for the drawing (file > properties) was still there.

Is there a setup difference between the two title blocks?

You can send me a sample if you wish. I may be able to look at it this week (by Wednesday). DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
The old template is not tied to the custom properties, the new template is. The custom properties are still there after the swap, just the notes in the new template that are linked to these properties do not show up.

Andrew
 
Don't know what version you're using, but this jives with my experience with SolidWorks 98. See "Template Changes" below for something I resurrected that I wrote a few years back on the subject. Don't know if the issues below are still applicable to more recent releases. There has to be a better way...


Viewer:

While “drawings” opened with the full SolidWorks Program will reflect changes made to the “part”, drawings opened with the SolidWorks Viewer will reflect the last saved “drawing” state.

If the SolidWorks Viewer is going to be used for viewing or printing drawings (desirable for cost and drawing control considerations) all linked drawing files must be opened and resaved after any changes to a part file, and/or drawing template file, to prevent reading or printing an outdated drawing. Use of the Viewer, in effect, defeats the associativity that is one of the strengths of the program.

Bottom line: I do not recommend using (or permitting the use of) the Viewer.


Template Changes:

In a similar vein, changes made to SolidWorks Drawing Template Files are not reflected in drawing files using that template, even after opening these files with the full SolidWorks Program and manually “forcing” a drawing “rebuild”.

This is an apparent “bug” in the program; I don’t know if it’s been addressed in 98 Plus. Template files in drawings can be replaced, however at the next drawing rebuild, all “Custom Properties” associated with the drawing will be overwritten. Changing the template causes the custom properties of the drawing to be overwritten with those associated with the particular drawing open at the last time the replacement template was saved. Options: 1) See if 98 Plus addresses this issue, or, 2) Don’t update templates, or, 3) Be aware that any custom properties in drawings will have to be manually re-entered and saved (tedious and error-prone).


 
I was able to make the embedded notes in the title block to show up after the swap. I still don't know what caused this problem. Here's what I did:

The surface finish in my title block is a note linked to custom property setup in the part. That note did show up after the swap. I looked at the differences between this note and the others. They were on a different layer:the note for surface finish was on Title text1 layer, all the others were on Title text2. I moved all of them on Title text1 and now they show up correctly after the swap.

Why the notes didn't show up when they were on Title text2 layer is still a mistery to me. If anybody has an explanation I would be happy to hear it.

There are still some weird things going on with this swap issue. I added to my program an option to replace a drawing with the sheet to none to my custom sheet format. The swap is done but the drawing is not updated untill I reload the sheet format. Anybody has an ideea why? And how to fix it?

Andrew/Netshop21
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor