Author Topic: Routine to move from block to block and fill attributes?  (Read 3154 times)

0 Members and 1 Guest are viewing this topic.

BlargaBlargaBB

  • Mosquito
  • Posts: 6
Routine to move from block to block and fill attributes?
« on: September 03, 2016, 06:54:30 PM »

I'm trying to see if this is possible. I have a drawing with many dynamic blocks, all with many attributes. Was curious if there was a routine that would select a single block - enable user to fill in the attributes click OK - then move onto the "next" block in the drawing until all the blocks in the drawing have been selected. Doing this manually would be very time consuming, having to select each block, edit the attributes, find the next block and repeat.

Anything like this remotely possible?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Routine to move from block to block and fill attributes?
« Reply #1 on: September 03, 2016, 07:17:47 PM »
multiple [enter]
ddatte [enter]
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

BlargaBlargaBB

  • Mosquito
  • Posts: 6
Re: Routine to move from block to block and fill attributes?
« Reply #2 on: September 03, 2016, 10:05:03 PM »
multiple [enter]
ddatte [enter]

Sorry I am new to this. How can I implement the code you wrote for this? What do I need to add to it?
Do you mean to just run those commands via command line and not through LISP? I wasn't able to get it working to move to the next block.

Thank you

« Last Edit: September 03, 2016, 10:34:20 PM by BlargaBlargaBB »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Routine to move from block to block and fill attributes?
« Reply #3 on: September 03, 2016, 10:47:43 PM »
Sorry. I'm away from my AutoCAD station posting from an iPad. I thought running the multiple command followed by the ddatte command should continuously prompt you to select attributed blocks. If no one posts anything I'll be on AutoCAD tomorrow and can cook up a little routine. Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

BlargaBlargaBB

  • Mosquito
  • Posts: 6
Re: Routine to move from block to block and fill attributes?
« Reply #4 on: September 03, 2016, 10:48:56 PM »
Sorry. I'm away from my AutoCAD station posting from an iPad. I thought running the multiple command followed by the ddatte command should continuously prompt you to select attributed blocks. If no one posts anything I'll be on AutoCAD tomorrow and can cook up a little routine. Cheers.

I'd appreciate that SO much.
The command works - but it just prompts you to manually select the next block after the first. Any way to automatically select another block would be WONDERFUL.

Thank you

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Routine to move from block to block and fill attributes?
« Reply #5 on: September 04, 2016, 08:30:31 AM »
Try the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:mddatte ( / ans app ent idx llp lst obj sel urp )
  2.     (cond
  3.         (   (or
  4.                 (not
  5.                     (setq sel
  6.                         (ssget "_X"
  7.                             (list
  8.                                '(000 . "INSERT")
  9.                                '(066 . 1)
  10.                                 (if (= 1 (getvar 'cvport))
  11.                                     (cons 410 (getvar 'ctab))
  12.                                    '(410 . "Model")
  13.                                 )
  14.                             )
  15.                         )
  16.                     )
  17.                 )
  18.                 (progn
  19.                     (repeat (setq idx (sslength sel))
  20.                         (setq ent (ssname sel (setq idx (1- idx)))
  21.                               obj (vlax-ename->vla-object ent)
  22.                         )
  23.                         (if (= :vlax-true (vla-get-isdynamicblock obj))
  24.                             (progn
  25.                                 (vla-getboundingbox obj 'llp 'urp)
  26.                                 (setq lst (cons (list ent llp urp) lst))
  27.                             )
  28.                         )
  29.                     )
  30.                     (null lst)
  31.                 )
  32.             )
  33.             (princ "\nNo attributed dynamic blocks found in the current layout.")
  34.         )
  35.         (   (setq app (vlax-get-acad-object))
  36.             (sssetfirst nil nil)
  37.             (while
  38.                 (cond
  39.                     (   (null lst)
  40.                         (prompt "\nAll blocks processed.")
  41.                     )
  42.                     (   (progn
  43.                             (sssetfirst nil (ssadd (caar lst)))
  44.                             (apply 'vla-zoomwindow (cons app (cdar lst)))
  45.                             (initget "Edit Skip eXit")
  46.                             (= "eXit" (setq ans (getkword "Edit attributes? [Edit/Skip/eXit] <Edit>: ")))
  47.                         )
  48.                         nil
  49.                     )
  50.                     (   (or (= "Skip" ans) (vl-cmdf "_.ddatte" (caar lst)))
  51.                         (setq lst (cdr lst))
  52.                         t
  53.                     )
  54.                 )
  55.                 (sssetfirst nil nil)
  56.             )
  57.             (sssetfirst nil nil)
  58.         )
  59.     )
  60.     (princ)
  61. )

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Routine to move from block to block and fill attributes?
« Reply #6 on: September 04, 2016, 11:12:11 AM »
Let's see ... carry the 1 ... yep, that should do it. Nicely done Lee.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Routine to move from block to block and fill attributes?
« Reply #7 on: September 04, 2016, 11:15:03 AM »
Let's see ... carry the 1 ... yep, that should do it. Nicely done Lee.

Cheers dude.  :-)

BlargaBlargaBB

  • Mosquito
  • Posts: 6
Re: Routine to move from block to block and fill attributes?
« Reply #8 on: September 04, 2016, 02:31:52 PM »
I appreciate the help of Lee and others, and it is my fault for not mentioning this before but I am not able to run this on AutoCAD for Mac. Running a google search I realize this is something not fully supported in the Mac version.

I also use a PC sometimes, but dont have access to it right now to test.

EDIT: I found this code online which worked, after manually selecting every block but it worked alright. I wish I could try your solutions, though.

Code: [Select]
;; Formerly TIP 1011: ME.LSP (C)1994, Gary Goode
;; (I've changed the name to DD.LSP and changed the defun to DD, B.K.)

;This program will let you pick and edit multi text and attributes
;by window, pick or crossing using dialog boxes.
;-----------------------------------------------------------------
(defun C:DD (/ A B C D E F G H J K L M )     
   (graphscr)
   (setvar "BLIPMODE" 0)
   (setvar "CMDECHO" 0)
   (setvar "HIGHLIGHT" 1)
   (prompt "\nMulti-Edit is loaded ...  ")
   (setq A (ssget) B (sslength A) C 0)                 
   (while (< C B) (setq D (ssname A C) E (entget D))
      (setq F (car E))
      (setq G (cdr E))
      (setq H (car G))
      (setq J (cdr H))
      (setq K "TEXT")
      (setq L "INSERT")
      (setq M "DIMENSION")
      (if (= J K)(command ".ddedit" D ""))   
      (if (= J L)(command ".ddatte" D ))
      (if (= J M)(prompt "\n You picked a dimension, I only do text or attributes ..."))(terpri) 
   (setq C (1+ C)))
   (princ)
); end me.lsp
« Last Edit: September 04, 2016, 02:44:05 PM by BlargaBlargaBB »

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Routine to move from block to block and fill attributes?
« Reply #9 on: September 04, 2016, 03:27:21 PM »
I appreciate the help of Lee and others, and it is my fault for not mentioning this before but I am not able to run this on AutoCAD for Mac. Running a google search I realize this is something not fully supported in the Mac version.

The following should hopefully be Mac compatible:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:mddatte ( / ans cmd idx lst sel tmp )
  2.     (cond
  3.         (   (not
  4.                 (setq sel
  5.                     (ssget "_X"
  6.                         (list
  7.                            '(000 . "INSERT")
  8.                            '(066 . 1)
  9.                             (if (= 1 (getvar 'cvport))
  10.                                 (cons 410 (getvar 'ctab))
  11.                                '(410 . "Model")
  12.                             )
  13.                         )
  14.                         )
  15.                 )
  16.             )
  17.             (princ "\nNo attributed blocks found in the current layout.")
  18.         )
  19.         (   (repeat (setq idx (sslength sel))
  20.                 (setq lst (cons (ssname sel (setq idx (1- idx))) lst))
  21.             )
  22.             (setq cmd (getvar 'cmdecho))
  23.             (setvar 'cmdecho 0)
  24.             (sssetfirst nil nil)
  25.             (while
  26.                 (cond
  27.                     (   (null lst)
  28.                         (prompt "\nAll blocks processed.")
  29.                     )
  30.                     (   (progn
  31.                             (vl-cmdf "_.zoom" "_o" (setq tmp (ssadd (car lst))) "")
  32.                             (sssetfirst nil tmp)
  33.                             (initget "Edit Skip eXit")
  34.                             (or (vl-catch-all-error-p (setq ans (vl-catch-all-apply 'getkword '("\rEdit attributes? [Edit/Skip/eXit] <Edit>: "))))
  35.                                 (= "eXit" ans)
  36.                             )
  37.                         )
  38.                         nil
  39.                     )
  40.                     (   (or (= "Skip" ans) (vl-cmdf "_.ddatte" (car lst)))
  41.                         (setq lst (cdr lst))
  42.                         t
  43.                     )
  44.                 )
  45.                 (sssetfirst nil nil)
  46.             )
  47.             (sssetfirst nil nil)
  48.             (setvar 'cmdecho cmd)
  49.         )
  50.     )
  51.     (princ)
  52. )
« Last Edit: September 04, 2016, 03:31:34 PM by Lee Mac »

BlargaBlargaBB

  • Mosquito
  • Posts: 6
Re: Routine to move from block to block and fill attributes?
« Reply #10 on: September 04, 2016, 07:40:58 PM »
That is MAC compatible and amazing!
Thank you all!

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Routine to move from block to block and fill attributes?
« Reply #11 on: September 05, 2016, 08:19:25 AM »
Excellent - you're welcome!  :-)