Author Topic: Placing Blocks Back together  (Read 247 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2507
  • I can't remeber what I already asked! I need help!
Placing Blocks Back together
« on: June 10, 2021, 07:25:58 AM »
I am creating this routine which utilizes Lees Block Counter and pburst commands.
I have dynamic blocks that need to be exploded. Then there are Blocks inside that i use for counting.
I am trying to figure a way put the dynamic blocks back together after the routine is done.

Code: [Select]
(vl-load-com)
(defun C:Count ()
(Alert "Explode Dynamic Block(s) First.")
(c:pburst)
(Alert "Select Blocks to Isolate.\n\nThen Select Blocks for Count Table.")
;Select Similar Blocks
(command "aecselectsimilar" (ssget) "" )
;isolateobjects
(command "_isolateobjects" "p" "")
(command "_isolateobjects" "p" "")
;Apply Block Counter
(C:COUNTER)
(command "_unisolateobjects" )

; ...........................................................
;I need a way to take the exploded dynamic blocks back together
;Thought is to Copy the Table, then UNDO everything back to the begining.
;Then Paste the Table back to the original coordinates.
;............................................................

;Copy Last (Block Count Table) Original Coordinates
(command "_copybase" "0,0" "last" "")
;Undo the command
(initcommandversion 2)
(command ".undo");Go back 1 Step
(command ".undo");Go back 2 Step
(command ".undo");Go back 1 Step
(command ".undo");Go back 1 Step
(command ".undo");Go back 1 Step
(command ".undo");Go back 1 Step
(command ".undo");Go back 1 Step
;paste original coordinates
(command "_pasteclip" "0,0")
(princ))
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2507
  • I can't remeber what I already asked! I need help!
Re: Placing Blocks Back together
« Reply #1 on: June 10, 2021, 12:17:23 PM »
I have it figured out. Thanks! Just had to state the number times to undo.... (command "_.undo" "4").
Civil3D 2020

BIGAL

  • Swamp Rat
  • Posts: 779
  • 30 + years of using Autocad
Re: Placing Blocks Back together
« Reply #2 on: June 10, 2021, 06:40:34 PM »
Look into (command "undo" "m") and (command "undo" "b") may be easier.
A man who never made a mistake never made anything

MSTG007

  • Gator
  • Posts: 2507
  • I can't remeber what I already asked! I need help!
Re: Placing Blocks Back together
« Reply #3 on: June 11, 2021, 09:55:26 AM »
I am using Lees Count Program and his Burst Program.
I first have lees burst program explode all dynamic blocks.
Then have the user select all the blocks the want to count.
Place the Count Table where the user wants it,
Last Undo everything to keep the dynamic blocks in tact.

But with this, the performance on this is so sluggish. lol

Code: [Select]
(defun C:count_table (/ acmcol adoc clsname keyname
newstyleobj tbldict tblstylename)
  (vl-load-com)
  (or adoc
      (setq adoc
     (vla-get-activedocument
       (vlax-get-acad-object)
     )
      )
  )
  (setq tbldict
(vla-item
   (vla-get-dictionaries
     (vla-get-database adoc)
   )
   "Acad_TableStyle"
)
  )
  ;; look in the tablestyle dictionary to search for our style name:
  (if (vl-catch-all-error-p
(setq tbstyleObj (vl-catch-all-apply
   (function (lambda()
         (vla-item tbldict "Count"))))));change table style name here
    ;; if table style "TblStyleName" does not exist:
  (progn
  (setq keyname      "NewStyle"
clsname    "AcDbTableStyle"
tblstylename "Count" ;change table style name here
  )
  (setq newstyleobj
(vlax-invoke tbldict 'Addobject keyname clsname)
  )
  (setq acmcol (vla-GetInterfaceObject
(vlax-get-acad-object)
(strcat "AutoCAD.AcCmColor." (itoa (atoi(getvar "acadver"))))
       )
  )
  ;;(vlax-put acmcol 'Colorindex 121)
  (vlax-put newstyleobj 'Name TblStyleName)
  (vlax-put newstyleobj 'Description "Your description here")
  ;or use style name as the description
  (vlax-put newstyleobj 'HorzCellMargin 3.00) ;;0.06
  (vlax-put newstyleobj 'VertCellMargin 3.00) ;;0.06
  (vlax-put newstyleobj 'TitleSuppressed :vlax-false)
  (vlax-put newstyleobj 'HeaderSuppressed :vlax-false)
  (vlax-invoke newstyleobj 'SetColor acDataRow acmcol)
  (vlax-invoke newstyleobj
    'SetBackgroundColorNone
    acDataRow
    :vlax-false
  )
  (vlax-invoke newstyleobj 'SetTextStyle acDataRow "Standard");change textstyle name here
  (vlax-invoke newstyleobj 'SetTextHeight acTitleRow 4.00) ;;0.25
  (vlax-invoke newstyleobj 'SetTextHeight acHeaderRow 3.00) ;;0.20
  (vlax-invoke newstyleobj 'SetTextHeight acDataRow 3.00) ;;0.18
  (vlax-invoke newstyleobj 'SetGridVisibility acVertInside acDataRow :vlax-true)
  (vlax-invoke newstyleobj
    'SetAlignment
    acDataRow
    acMiddleCenter
  )
  ;| ETC  add another options here|;
  )
    ;;inform user if style exist:
    ;;(princ "\n\t\t ***\tStyle already exist\t***")
    )
  (SETVAR "CTABLESTYLE" "Count")
  (princ)
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



(vl-load-com)
(defun C:CountTB ()
;;(command "UNDO" "B")
;Setup the Table Style
(C:Count_Table)

;;(Alert "Select Dynamic Block(s) to Burst First.")
(command "aecselectsimilar" (ssget "_x" '((0 . "INSERT")(2 . "`*U*"))) "" )
(c:pburst)

(Alert "Select the Block(s) to isolate and it will select all similar blocks.")
;Select Similar Blocks
(command "aecselectsimilar" (ssget) "" )

;isolateobjects
(command "_isolateobjects" "p" "")

;Apply Block Counter
(Alert "Select All Block(s) to be counted.")
(C:COUNT)

;Copy Last (Block Count Table) Original Coordinates
(command "_copybase" "0,0" "last" "")

;Undo the command
(initcommandversion 2)
(command ".undo" "10")
;;(command "UNDO" "B")

;paste original coordinates
(command "_pasteclip" "0,0")

(command "_regenall")
(princ))
Civil3D 2020