Seek a lisp to automatically update the drawing version of current layout

Seek a lisp to automatically update the drawing version of current layout

skchui6159
Advocate Advocate
1,860 Views
16 Replies
Message 1 of 17

Seek a lisp to automatically update the drawing version of current layout

skchui6159
Advocate
Advocate

I want to seek a lisp for automatically to add a version of the specific layout.

 

Before:

skchui6159_0-1733903675919.png

After update version:

skchui6159_1-1733903723561.png

if the A version was existed, I want the version was updated like that below:

skchui6159_2-1733904709296.png

ORIGINAL SIGNED AND VERSION B WAS ADDED INTO THE DRAWING. 

ALL MATERIAL ARE COPYED BY OTHER FILE and BY PASTING by basepoint THE REFERENCE BY OTHER AUTOCAD FILE .

skchui6159_3-1733904968950.png

2. ANOTHER LISP NEED TO ADD THE ORIGINAL SIGNED BY PASTING THE REFERENCE BY OTHER AUTOCAD FILE 

BEFORE:

skchui6159_5-1733905109864.png

AFTER:

skchui6159_6-1733905197584.png

 

skchui6159_4-1733905061410.png

 

Is it possible? Anybody can help?

 

 

0 Likes
Accepted solutions (1)
1,861 Views
16 Replies
Replies (16)
Message 2 of 17

ec-cad
Collaborator
Collaborator

Instead of Lines & MText, make your images from Blocks.

See Blocks REVA & REVB in your sample drawing, uploaded to this Message.

Once you insert either, a Lisp can find the insertion point of either block,

In the case of 'none' found, insert REVA at your picked point. You fill in the details.

Then, when adding your REVB block, can change the A to a B, etc. Again, filling in

the rest of the details. RevB can also be inserted (below) REVA automatically.

 

ECCAD

0 Likes
Message 3 of 17

Sea-Haven
Mentor
Mentor

Like @ec-cad there is numerous examples of adding revisions either letter or numbers or can be auto detected as we used A, B etc for Prelim then 1,2,3 for Issued. The simplest is make a block with multiple attributes just don't have any text in the attributes I often use "." as the default. I have  a title block with 25 attributes, so its not a problem.

 

Once you make the block post it and then people can make suggestions about rev updates.

 

 

0 Likes
Message 4 of 17

skchui6159
Advocate
Advocate

Sir, Thank you for your help! Could you also provide the lisp to find the insert point of the layout? Thank.

0 Likes
Message 5 of 17

ec-cad
Collaborator
Collaborator

OK, a question. Does your version support Lisp ? Some LT versions do not. Latest do.

If you mean the insertion point of the 'block' named "a1titleblock", yes, you can
find that - in the current Layout Tab.
Here's a sample code to extract that point in paperspace and add REVA to that titleblock.

You just drag / drop the GIP.lsp into your drawing, at current layout.

If it finds 'a1titlteblock', it will add REVA. Same can be done with REVB, automated later.

;; Get Insertion Point of 'a1titleblock'

 (defun get_insertion_point (blockname)
  (if blockname
   (progn
    (setq ip nil)
    (setq ss (ssget "X" (list (cons 410 (getvar "ctab"))(cons 0 "INSERT")(cons 2 blockname))))
    (if ss
     (progn
      (setq blkent (ssname ss 0))
      (setq ip (cdr (assoc 10 (entget blkent))))
     ); progn
    ); if
   ); progn
  ); if
 ip
); function

 (setq block "a1titleblock"); put your blockname here
 (setq INS_PT (get_insertion_point block)); now, go get the insertion point
 (if INS_PT
  (progn
   (princ  (strcat "\nInsertion Point of " block " = \n"))
   (princ INS_PT)
   (princ)
  ); progn
  (princ "Insertion Point not found")
 ); if

;; If INS_PT is found..
;; Insert REVA at top intersection of the Titleblock in 1st location.
 (if INS_PT
  (progn
   (setq X (car INS_PT) Y (cadr INS_PT)); get the X and Y coordinates
   (setq OFFX 821.0 OFFY 320.0); offset values for 1st position
   (setq X1 (+ X OFFX) Y1 (+ Y OFFY))
   (setq INS_PTA (list X1 Y1 0.0)); Insertion point for REVA block
   (setvar "ATTREQ" 0); Insert command won't ask for Attributes
   (command "_-insert" "REVA" INS_PTA "1" "1" "0"); Insert REVA block
   (command "_DDATTE" "l")
  ); progn
 ); if
 (princ)

ECCAD

 

0 Likes
Message 6 of 17

Sea-Haven
Mentor
Mentor

One of the fixes for our company standard was that the title block was at 0,0 so this will go through all layouts and move all the title blocks to correct 0,0. 

 

; moves all objects in pspace to 0,0 alignment
; By AlanH 

(defun movelayouts ( / doc ed k k len maxy minxy oldsnapen plotabs ss xy)
(PROMPT ".....now moving dwgs....")

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
  (setq plotabs (cons (vla-get-name lay) plotabs))
)
(setq plottablist (acad_strlsort plotabs))
(setq len (length plottablist))
(setq oldsnap (getvar "osmode")) 
(setvar "osmode" 0)

(setq en (entsel "Pick Title Block:"))
(setq  ed (entget (car en)))
(setq K 0)
(repeat len
  (setq name (nth K plottablist))
  (princ name)
  (if (/= name "Model")
    (progn
    (setvar "ctab" name)
    (setq minxy  (getvar "extmin"))
    (setq maxxy (getvar "extmax"))
   ; (setq ss (ssget "_X" (list (cons 0 "INSERT")  (cons 410 name) (cons 2 (cdr (assoc 2 ed))) ) ))
(setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 (cdr (assoc 2 ed))) ) ))    
(setq n (sslength ss))
    (setq en (ssname ss 0))
    (setq xy (assoc 10 (entget en)))
  ; insertion pt   (setq xy (assoc 10 el)) 
    (setq xy (list (cadr xy)(caddr xy)))
    (command "move" "w" minxy maxxy  "" xy "0,0")
    (command "zoom" "E")
    ) ;end progn
) ; end if
(setq K (+ K 1))
(princ k)
(setq ss nil)
(setq xy nil)
) ; end repeat

(setvar "osmode" oldsnap)
(princ)
)
(movelayouts)
Message 7 of 17

ec-cad
Collaborator
Collaborator

 

Skchui6159, (what a handle..)

Here's a lisp to find any previous Revision blocks, and inserts either REVA if none found,

or REVB if any REV* block was found. It checks for previous blocks, if found, increments

the Revision Letter, and inserts the next Rev block just below the previous.

How to use this lisp:

With Notepad, edit or create a file "acaddoc.lsp" and place it in your Acad\support  folder.

Inside that .lsp, add:

(load "REVME.lsp")

For each drawing open, the acaddoc.lsp is read-in and holds the functions in memory.

IF the functions have 'command' type defun's e.g. (defun C:REVME ().. then all you do

is at the Command Line, type in REVME<Enter key> to run that function.

Copy the attached .lsp and the blocks REVA and REVB to the Acad\support folder.

Then, open your test drawing, type in REVME and see what happens.

🙂

ECCAD

 

 

0 Likes
Message 8 of 17

Sea-Haven
Mentor
Mentor

@skchui6159  if your going to start using lots of lisp programs than add to a menu, a toolbar or the Ribbon. There is 130+ lisps behind this. One of 4 custom menu's. I never add to acaddoc.lsp.

 

SeaHaven_0-1734216475205.png

 

 

 

 

0 Likes
Message 9 of 17

ec-cad
Collaborator
Collaborator

If you have more than (1) ISO size for your titleblocks (your sample has 'a1titleblock', so I would

assume there's an 'a2titleblock' and maybe 'a0titleblock'), you will need a modification to

revme.lsp that gets the drawing extents (getvar 'extmax'), then figures out which titleblock you have,

then calculates the Insertion point(s) from 0,0 so the insert falls in the correct spot.

Another way is to check which titleblock is present, and set the insertion point(s).

Just let us know if that's an issue.

ECCAD

 

0 Likes
Message 10 of 17

Sea-Haven
Mentor
Mentor

Something like this will work. You then look inside the ss for the name of the title. It should only return 1 entity as you should only have 1 title block per layout. The titles were set to 0,0 insert so no need to worry about insertion.

 

(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "TITLE*,A0_Landscape_XXX,A1_Landscape_XXX,A1_Portrait_XXX,A2_Portrait_XXX,A2_Landscape_XXX,A3_TITLEBLOCK_XXX")(cons 410 (getvar 'ctab)))))

 

(cond
((= blkname "A0_Landscape_XXX" )(setq sc "1=1" psize "ISO full bleed A1 (841.00 x 1189.00 MM)" ll "-5,-5" ur "1175,837" orien "Landscape"))
...
)
0 Likes
Message 11 of 17

skchui6159
Advocate
Advocate

How to add the lisp to library?

0 Likes
Message 12 of 17

skchui6159
Advocate
Advocate

OK, I try to make the block.

0 Likes
Message 13 of 17

skchui6159
Advocate
Advocate

Thank you very much! It is helpful. Can the block also add current day automatically with lisp?

0 Likes
Message 14 of 17

skchui6159
Advocate
Advocate

Thanks for your sharing. However, It show the error: misplaced dot on input. How can be solve?

skchui6159_0-1734311533484.png

 

0 Likes
Message 15 of 17

Hassan_MohammadARCYT
Participant
Participant

I believe it is better to arrange by category.

Hassan_MohammadARCYT_0-1734352152600.png

 

0 Likes
Message 16 of 17

ec-cad
Collaborator
Collaborator
Accepted solution

You say: "Can the block also add current day automatically with lisp?"

Sure. I thought you would have MM / YY format, so I built those blocks for 

tagnames 'MM and 'YY. I see your sample has MM/DD Month and Day.

Here's an update revme.lsp that does that.

ECCAD

 

0 Likes
Message 17 of 17

skchui6159
Advocate
Advocate

Thank you very much! The lisp very helpful!

0 Likes