Author Topic: Is there a better way for this ?  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1423
Is there a better way for this ?
« on: February 12, 2013, 05:11:53 AM »
Thanx irneb - LLE
I want to move a block from insertion point to around point
comes in mind 2 ways
- Changing DXF Value. But the attribute does not move
Code: [Select]
(if (setq sel (ssget "_X" '((0 . "INSERT") (2 . "`*U*,GM-Limits") (66 . 1)))) ; change dxf
  (progn
    (defun round (number by) (if (zerop by) number (+ (* (fix (/ number (setq by (abs by)))) by) (if (< (* 0.5 by) (rem number by)) by  0 ))))
    (setq entity (ssname sel 0))
    (setq dxfdata (entget entity))
    (setq old-dxf (assoc 10 dxfdata))
    (setq new-dxf (cons 10 (list (Round (nth 1 old-dxf) 5) (Round (nth 2 old-dxf) 5) 0.0)))
    (setq dxfdata (subst new-dxf old-dxf dxfdata))
    (entmod dxfdata))
  (princ "\nBlock ( Limits ) not found.")
  )

- Move the the block
Code: [Select]
(if (setq sel (ssget "_X" '((0 . "INSERT") (2 . "`*U*,GM-Limits") (66 . 1)))) ; move
  (progn
    (defun round (number by) (if (zerop by) number (+ (* (fix (/ number (setq by (abs by)))) by) (if (< (* 0.5 by) (rem number by)) by  0 ))))
    (setq entity (ssname sel 0))
    (setq dxfdata (entget entity))
    (setq old-dxf (assoc 10 dxfdata))
    (setq pnt1 (list        (nth 1 old-dxf)           (nth 2 old-dxf)           (nth 3 old-dxf)   ))
    (setq pnt2 (list (Round (nth 1 old-dxf) 5) (Round (nth 2 old-dxf) 5) (Round (nth 3 old-dxf) 5)))   
    (vl-cmdf "_.move" sel "" pnt1 pnt2)
    )
  (princ "\nBlock ( GM-Limits ) not found.")
)

Which one is better?
Is there a better way than these 2 options?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Is there a better way for this ?
« Reply #1 on: February 12, 2013, 05:38:43 AM »
my2cents: entmod maybe is faster and ignores OSMODE.

kpblc

  • Bull Frog
  • Posts: 396
Re: Is there a better way for this ?
« Reply #2 on: February 12, 2013, 06:45:56 AM »
I prefer to do these tasks by ActiveX. I think the fastes way will be to make all layers off, changes all BlockReferences and then restore layer status. Sometimes this way is faster.
Sorry for my English.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Is there a better way for this ?
« Reply #3 on: February 12, 2013, 07:36:16 AM »
Alter the insertionpoint property of the block or use vla-move.
With entmod you will need to also update the positions of every attribute reference in the block; and with a call to the MOVE command you need to account for Object Snap and possibly alter CMDECHO to suppress the prompts at the command-line.
« Last Edit: February 12, 2013, 07:39:47 AM by Lee Mac »