Is there a way to insert Title Block/Template into existing project and drawings (EPLAN>DWG) ?

Is there a way to insert Title Block/Template into existing project and drawings (EPLAN>DWG) ?

rchacinRUGAK
Contributor Contributor
1,839 Views
34 Replies
Message 1 of 35

Is there a way to insert Title Block/Template into existing project and drawings (EPLAN>DWG) ?

rchacinRUGAK
Contributor
Contributor

Hello, community, 

 

I'm working on a set of drawings imported from EPLAN. They lack any "intelligence" of course, including the fact the would've-been title block is just a block without any attributes, so changes need to be made manually on each page. Minor edits have slowly evolved into multiple pages, including the addition of new sheets, and the cumulative of having to manually edit minor details page by page (sheet count, drawn by, logo/image frame, page set up, etc.) is beginning to amount to something. 

 

I am wondering is there is a way to insert/replace this faux title block with the real one (i.e.: .dwt template) in the existing project, such that the contents of the (dozens of) pages stays the same, but  I have a real title block that can be globally updated more easily. Hopefully in a swift motion 🤞

 

Given the amount of pages, copying and pasting each drawing into a new project and and new sheet (using the right .dwt template with title block) would void the purpose.

0 Likes
Accepted solutions (1)
1,840 Views
34 Replies
Replies (34)
Message 21 of 35

rchacinRUGAK
Contributor
Contributor

@arshdeepsingh404 That's so elegantly simple — it seems to be working exactly as expected. Thank you so much!

 

As to the attributes within the old frame/TB, as @rhesusminus pointed out, they are not attributes, just text (which a big part of the original problem). At this stage, with the advice you've provided I'm able to circumvent the most daunting aspects of this task. After that, having to rename some drawings or add [non-sequential] sheet numbers is straightforward enough compared to the earlier alternative. I appreciate it, it's been both helpful and extremely educational 🤝🤝

 

That said, you just opened the door to my curiosity and I can't help but wonder how far one could go on this automation stretch we're on. With the file names containing Installation, Location, and Sheet #, I wonder if through scripting and/or AutoLISP one could somehow read that and write to the Drawing Properties

0 Likes
Message 22 of 35

rchacinRUGAK
Contributor
Contributor

@rhesusminus you know what, I noticed that early on and thought it was a little odd, but I just attributed it to it being "EPLAN stuff", and everyone had suggested. Granted, as you said, knowing Caddy++ is/was would've helped😅.

 

Thanks for pointing this out, it's going to be helpful in the future.

0 Likes
Message 23 of 35

arshdeepsingh404
Collaborator
Collaborator

Hello @rchacinRUGAK 

 

I am glad you found this helpful and educational. The next level of automation would be write an AutoLISP program that can do much advanced tasks.
@rhesusminus had a very good point about everything being text only which makes things hard but it still might be possible.

We would have to split it into small tasks on how we want to handle it but most of it should be do able after some trial and error. On top of my head, I think it will be following sequence:

 

  1. We would create a project with the old drawings, so that a project folder and the necessary project files are created.
  2. Then we will open drawing number 1
  3. We would select text in fixed co-ordinates, read their value and store them into memory/external temp ASCII file. (The text must be in same spot on all drawings for this to work, which I think it should be)
  4. Then we would delete the existing title block, de-attach the image xrefs.
  5. Then Insert the new title block.
  6. The load the text from memory/external file and update the attribute values. (We would of course have to discuss what attributes should be mapped to what text)
  7. Most importantly, we will have to update drawing properties, This is the most tricky part of all. Not everything is stored in the drawings for properties. Sheet Number is stored in WD_M Block on the current drawing. Sheet Description is stored in the project folder as part of the WDP file.
  8. Then just repeat steps to do this for all drawings.

 

I have some programs that I have written previously that we might be able to re-purpose for some parts here.

 

I usually weigh the frequency and usefulness of a custom program against the time required to write and test it. It's important to consider whether the time saved on the task justifies the effort, especially if the command will be used repeatedly in the future.

 

That said, I’m passionate about customization and always eager to learn. If you're interested, we can get started with the program! Who knows—you might end up loving AutoLISP as much as I do and find yourself automating every repetitive task with it, just like me.

 

I should have some spare time next week to look into it further. I’ll need a sample DWG file of the old drawing (which I believe you’ve already shared) and the new title block. Feel free to strip out any confidential information, I just need the attributes and their locations.

 

Cheers

 

Arshdeep Singh
C.Tech, CMSE®

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 24 of 35

rchacinRUGAK
Contributor
Contributor

@arshdeepsingh404,

 

You have my curiosity on the possibilities of AutoLISP — I am all for letting computers take care of as many repetitive tasks as possible while I focus on figuring out more tangible problems. If you think you have the time to give it a shot, I'd be ecstatic to see what that code ends up looking like and learning how to use it for future problems!

 

In regards to the files, you are correct, the ones I shared previously are true representations of the project. The new title block (attached TB Example.dwg) is based on that, where all the "text" fields have been turned into attributes (retaining the same location and size, so it would be a like-for-like replacement). 

 

In case it helps, this is the distribution I chose per the .wdt file: 

 

BLOCK = TB Example*
SHT = SHEET
`#_SHT = SHEETMAX
SHT_DESC = DD1
FUNCTION = IEC_I
LOCATION = IEC_L
ORDER_DESC1 = LINE1
ORDER_DESC2 = LINE2
ORDER_DESC3 = LINE3
PROJECT_NAME = LINE4
DWG_NAME = LINE5
DRWN_BY = LINE6
DATE = LINE7
REV = LINE8

 

 

0 Likes
Message 25 of 35

rchacinRUGAK
Contributor
Contributor

Hi, @rhesusminus, sorry to keep reviving this topic, but I was hoping I could pick your brain one last time: 

 

I am told these drawing were indeed made in EPLAN (straight from the drafters) — I found that curious, but all right. With that in mind, would you be able to make a recommendation about which specific settings they should select in the future during the project export process to ensure someone like me would get the best possible scenario to start working them out in AutoCAD Electrical?

 

Just for reference, these are some of the main issues I've been trying to circumvent: 

  • Title blocks have lost all attributes (though through this thread I've found a way to redo them easily 👍)
  • Much like title blocks, tables lose their structure — they're just a block in the shape of table, with text scattered (in the model space) on top of it in what would be the cell spaces.
  • Files have an unusual naming convention, to the effect of "wwwww - ### wwwwwwwww - #### ()" where the first word is always the same, the numbers after that are not sequential, and the last string of numbers is the actual sheet number. Sorting several hundred pages in this manner automatically is not possible as far as I can tell. And doing it manually is...slow. 
  • Components within the drawing are just blocks. Some with useable attributes, others are blocks within blocks, so quickly editing the attributes or editing proves time consuming (although I gather from the drawing you shared I may be stuck with it). 

But ultimately, what specific settings should I put forth to help eliminate or minimize these issues when they're exporting (if any at all)?

0 Likes
Message 26 of 35

rhesusminus
Mentor
Mentor

No, they are NOT made in Eplan. They can claim that as much as they want, it still won't be true.

Se thee attached dwg above, with the default export from Eplan. You'll see blocks with attributes and no random filenames. 

 

If you have access to that original "EPLAN" project, feel free to send it to me and I'll dig a little further. 


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 27 of 35

rchacinRUGAK
Contributor
Contributor

@rhesusminus unfortunately, I wouldn't be able to get the original project ☹️  But I gather then that quite literally hitting the "Export" button (as it comes) on EPLAN would be sufficient (as described here)? 

 

I've attached an (edited) screenshot of the exporting options they see — hopefully this provides some of the context I've been unable to give. 

rchacinRUGAK_1-1739473244821.png

 

rchacinRUGAK_0-1739473162729.png

 

0 Likes
Message 28 of 35

rhesusminus
Mentor
Mentor

Those screenshots are NOT Eplan 😂

 

So, I really cannot help with those screenshots.

 


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 29 of 35

rchacinRUGAK
Contributor
Contributor

@rhesusminus that does help. As I was writing the message I zoomed in on that that lowercase "a" logo and I questioned myself even further. It's just the dotted background gave me some hope. But I'll lead with that — thank you. 

0 Likes
Message 30 of 35

ccad2509
Advisor
Advisor

Hello Trond

thius [pretty much tells you everything about how Useless ACADE is as see electrical undeaneath all the wrapping is an  Autocad clone engine

 

i could have told you all this ayt rh begining but was unavailble for over a week  the screen shot definatley looks like See electrical expert 

 

heres how see elctrical sets up exactly what orignal poster wants but from see electrical to acade

Screenshot 2025-02-14 073255.png

Message 31 of 35

rchacinRUGAK
Contributor
Contributor

@ccad2509 is there a link to this site you could share? I'd like to read further into it. 

 

SEE Electrical/Caddy++ seems a little obscure so Googling it is leading to all kinds of places except where I want to go. 

0 Likes
Message 32 of 35

arshdeepsingh404
Collaborator
Collaborator

Hello @rchacinRUGAK 

 

Try the attached version 1 of the ReplaceTitleBlock command. I have attached a PDF on how to load an AutoLISP program.

 

You will need to update the following items in the " " marks according to your project. 

 

  (setq NewTitleBlockLocation "C:\\Users\\Virtual Machine\\Desktop\\\Replace TB\\TB Example.dwg")   ; Define title block Location, Replace with your title block location, Use the \\ for path 
  (setq XREFimageName "Image1")                                                                     ; Define XREF image name to detach,  Replace "Image1" with the name of XREF image found in your title block
  (setq TitleBlockName "TB Example")                                                                ; Define new title block Name, Replace "TB Example" with the actual block name

 

 

Add all drawing to an AutoCAD Electrical Project and Open First Drawing. Load the LISP program and call ReplaceTitleBlock command.

The program uses the following pattern.

 

  1. Select the title block using FENCE method and Explode.
  2. After exploding, The text would be available to be selected and read.
  3. Select and read the following text from fixed coordinates. Sheet Number, Sheet Description, IEC_Location, IEC_Installation.
  4. Store Sheet Number, Sheet Description, IEC_Location, IEC_Installation in memory.
  5. Undo command to undo block explode so it can be selected and deleted.
  6. Select old title block with fence method, and delete.
  7. Remove XREF image.
  8. Insert new title block.
  9. Update attributes on the new title block: Sheet Number, Sheet Description, IEC_Location, IEC_Installation.
  10. Update WD_M block which store the following drawing properties: Sheet Number, IEC_Location, IEC_Installation.

Sheet Description is stored in the .wdp file in the project folder, Once you have the command working well for these steps, I will add additional code to to update description in drawing properties as well.

 

If some of the text is missing, we might need to redefine the selection window fixed coordinates.

 

  (setq SheetDescPt1 '(173 25))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT
  (setq SheetDescPt2 '(260 18))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT
  
  (setq SheetNumberPt1 '(385.5 15))                                                                 ; Sheet Number text window selection coordinates ending point, Selection window must cover the entire TEXT
  (setq SheetNumberPt2 '(398 10.5))                                                                 ; Sheet Number text window selection coordinates ending point, Selection window must cover the entire TEXT
  
  (setq LocationCodePt1 '(349 15.5))                                                                ; Location code text window selection coordinates ending point, Selection window must cover the entire TEXT
  (setq LocationCodePt2 '(384 11.5))                                                                ; Location code text window selection coordinates ending point, Selection window must cover the entire TEXT
  
  (setq InstallationCodePt1 '(311 15.5))                                                            ; Installation code text window selection coordinates staring point, Selection window must cover the entire TEXT
  (setq InstallationCodePt2 '(345 11.5))                                                            ; Installation code text window selection coordinates ending point, Selection window must cover the entire TEXT

 

 

Once you are ready to run this project wide, you should make the LISP program automatically load to every drawing to make things easier. This way you will not need to run APPLOAD on every drawing, The ReplaceTitleBlock command will be already available on the command line to be called.

Read one of my blogs that explain step by step on how to automatically load LISP files. The section that you will be interested is in Adding LISP files to CUI in the following blog: How to Add Custom AutoLISP Commands Into the AutoCAD Ribbon

For running it as a batch command across multiple drawings, I am thinking to simply use a script that calls ReplaceTitleBlock command the same way you batch script before with Project Wide Utilities.

 

I have commented every line of the code to make it more understandable. Let me know if you have any questions.

 

Arshdeep Singh
C.Tech, CMSE®

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 33 of 35

ccad2509
Advisor
Advisor

Obsure  you mean i cant find anything on youtube or google !!!!!

FYI  by units it sells more than any other dedicated ecad product and far technically better than ACDE

 

as for an answer to your question no as all you need to knw is in the help files or from tech support who wil answer thae phone

 

 

0 Likes
Message 34 of 35

rchacinRUGAK
Contributor
Contributor

Hi, @arshdeepsingh404, sorry the delay - other responsibilities have consumed most of my time lately. Thank you for sharing, I can see what you meant by it being a powerful tool. I'll be looking into polishing my AutoLISP skills after this.

 

I've reviewed the code and I think I understand most of its operating principle, except the Read-text Function. It seems to run well on individual pages, which is great! Just having the sheet number alone is going to be a big help in sorting these out properly (and automatically). 

 

EDIT/PS:
@arshdeepsingh404, I was just thinking of ways to write to the Drawing Description, and I realized that I ran into a situation where a second Description field had to be added (after my first round of attempts). See attachment for reference. 

 

I'm assuming that in order for the Lisp to work with this new addition, then it should be modified to include:

 

(defun c:ReplaceTitleBlock ( / NewTitleBlockLocation XREFimageName TitleBlockName SheetDescPt1 SheetDescPt2 SheetDesc2Pt1 SheetDesc2Pt2 SheetNumberPt1 SheetNumberPt2 LocationCodePt1 LocationCodePt2 InstallationCodePt1 InstallationCodePt2 Selection SheetDescription SheetNumber LocationCode InstallationCode EntityName)

  (defun *error* (x) (princ "\n*Cancel*"))                                                          ; Define error function

  (setq NewTitleBlockLocation "C:\\Users\\Virtual Machine\\Desktop\\\Replace TB\\TB Example.dwg")   ; Define title block Location, Replace with your title block location, Use the \\ for path 
  (setq XREFimageName "Image1")                                                                     ; Define XREF image name to detach,  Replace "Image1" with the name of XREF image found in your title block
  (setq TitleBlockName "TB Example")                                                                ; Define new title block Name, Replace "TB Example" with the actual block name
  
  (setq SheetDescPt1 '(173 25))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT
  (setq SheetDescPt2 '(260 18))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT

  (setq SheetDesc2Pt1 '(173 18))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT
  (setq SheetDesc2Pt2 '(260 10))                                                                     ; Sheet Description text window selection coordinates ending point, Selection window must cover the entire TEXT

 

 "SheetDesc2Pt1 SheetDesc2Pt2"

 

And then subsequently, all references to that SheetDesc2Pt1 SheetDesc2Pt2 should be added throughout the code? Such are an Error line for "not found", a setq for EntityName and update titleblock, etc. I don't see anything within the Read-Text Function that would be affected, so I infer that part would stay the same. 

______________________________________________

On a slightly separate line of thought, I noticed that after the new title block has been inserted and updated, one could manually do Drawing Properties>Description1:>Pick>> and manually selecte the text to be used. I wonder if there's a way to codify that and use a set of coordinates for each text field. As far as I'm concerned ACEDRAWINGPROPS cannot be run without a window prompt and manual input — what do you think? 

 

You probably have a more sophisticated method, but it just got me thinking. 

 

0 Likes
Message 35 of 35

arshdeepsingh404
Collaborator
Collaborator

Hello @rchacinRUGAK 

 

No problem, I am glad you found the program useful. You are correct about duplicating the sheetdesc code to create sheetdesc2.

Attached is the updated code that will look for a sheet description 2 text as well.
I am assuming you will change the SHEET_DESC attribute to SHEET_DESC_1 and add a new attribute called SHEET_DESC_2 to your new title block.

 

 

Read-Text Function Explanation

-----------------------------------------------------------------------------------------------------

The Read-Text Function is sub function that can be a called again and again. 

The function can be called anywhere from the program and expect two co-ordinate positions to passed to it while using, It will then do a crossing window between the two points and return any text that is captured and read inside that area.

 

Since its the same piece of code for reading text, we don't need to write the code multiple times (for every time we are trying to read something), Instead a function is better and we can simply send it different positions to look inside every time we call it. So, you are correct, there would be no changes to Read-Text function.

 

(setq SheetDescription1 (Read-Text SheetDesc1Pt1 SheetDesc1Pt2))

In this line, We are setting a variable called SheetDescription1

The value of the variable would be the value returned by the (Read-Text) function

Here we are going to give the function 2 coordinate positions on where we expect sheet description 1 text to be (Read-Text SheetDesc1Pt1 SheetDesc1Pt2)

 

 

  (setq SheetDescription1 (Read-Text SheetDesc1Pt1 SheetDesc1Pt2))                                  ; Read sheet description Text from fixed co-ordinates
  (setq SheetDescription2 (Read-Text SheetDesc2Pt1 SheetDesc2Pt2))                                  ; Read sheet description Text from fixed co-ordinates
  (setq SheetNumber (Read-Text SheetNumberPt1 SheetNumberPt2))                                      ; Read sheet number Text from fixed co-ordinates
  (setq LocationCode (Read-Text LocationCodePt1 LocationCodePt2))                                   ; Read location code Text from fixed co-ordinates
  (setq InstallationCode (Read-Text InstallationCodePt1 InstallationCodePt2))                       ; Read installation code Text from fixed co-ordinates

 

;=============================================================================================================================================================================================
;=========================================================================== Read-Text Function ==============================================================================================
;=============================================================================================================================================================================================

; This function read TEXT within a window of two points provided by user and returns the text contents
; Function Syntax: (Read-Text Point1 Point2)
; Function Returns: TextContent

(defun Read-Text (Pt1 Pt2 / Selection i Entity EntityData TextContent)
  (setq TextContent "")                                                                             ; Reset TextContent variable
  (setq Selection (ssget "W" Pt1 Pt2 '((0 . "TEXT"))))                                              ; Select TEXT in window
  (if (and Selection)                                                                               ; If a valid TEXT is found
    (progn                                                                                          ; Then do the following
      (setq Entity (ssname Selection 0))                                                            ; Get the first entity from the selection set
      (setq EntityData (entget Entity))                                                             ; Retrieve entity data
      (setq TextContent (cdr (assoc 1 EntityData)))                                                 ; Extract TEXT content from DXF group code 1
    )
    (princ "\nNo TEXT found in the specified window.")                                              ; Message if no TEXT is found
  )
  TextContent                                                                                       ; Return the extracted text content
)

 

 

 

 

Drawing Properties

-----------------------------------------------------------------------------------------------------

Regarding the Drawing Properties>Description1:>Pick>> option, That is more meant for manual control for making it easier for users.
Most of the programs that run automatically on multiple drawings tends not to use dialog box again and again. It is also not very straightforward to interact with dialog boxes using code, Like you saw in scripts, we were calling dialog-less versions of the command.

 

That being said, ACADE offers APIs to control most of the electrical commands with code. There is always something useful there when searching for a code sample.

 

arshdeepsingh404_0-1741284732093.png

 

arshdeepsingh404_1-1741284773613.png

 

 

Side note: This program is doesn't needs to be that long, I am printing a lot of stuff to the command line for a new user to understand what's happening in the background, Like was sheet number found, was it updated etc.
The code would run fine even if you took out most of the princ stuff. It just makes it easier to track any unexpected results when you are printing the progress to command line.

 

Let me know if you have more questions, Happy coding!

 

Arshdeep Singh
C.Tech, CMSE®

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature