Jump to content

Automated Scale blocks preserving negative values


Recommended Posts

Posted

You know, I have been using this lisp made by David and modified by me, this match selected blocks all selected blocks (normal, attribute, dynamic and annotative) to current dimscale.

 

It's a beauty, but now I realize that some blocks have negative x, y, z scale factor values (mirrored blocks) and I would like to preserve those values because usually the mirror was required for direction and it's necessary to preserve negative values when exist.

 

There are other block scaling routines but those routines use the

(command "scale" eachblockinsertion "insertionpoint" (/ newscale currentscale))

 

and when using those routines, they work until they find a negative value, then the routine stucks with this message

 

Value must be positive and nonzero.

; error: Function cancelled

 

Could there be a way to change each block's x,y,z value but preserving their original value sign (positive or negative)?

 

Anybody knows how?

 

;;; BXY by David Harrington; Modified by Paulo Gil Soto (added annotation scale reset to 1:1)
;;; updates selected blocks x,y and z values to current Dimscale
;;;
;;; Main Program
;;;
(defun c:Bu (/ ss xs ys zs num x na lst editxyz_error olcmdecho old_err) 
(defun editxyz_error (msg) 
 (if (or
   (= msg "Function cancelled")
   (/= msg "quit / exit abort")
  ) 
  (princ (strcat "Error: " msg))
 ) 
 (command ".UNDO" "E" "UNDO" "") 
 (setq *error*  old_err
    old_err  nil
 )
 (setvar "CMDECHO" olcmdecho)
 (princ)
) 
(setq old_err *error* 
   olcmdecho (getvar "CMDECHO")
   *error* editxyz_error
) 
(setvar "CMDECHO" 0)
       (setq dms (getvar "dimscale"))
(command ".UNDO" "BE")  (prompt "\nSelect Blocks to match current dimscale: ")
(cond
 ((setq ss (ssget '((0 . "INSERT"))))
        (command "-objectscale" ss "" "add" "1:1" "" "cannoscale" "1:1") 
  (setq num (sslength ss))
  (setq x 0)
  (repeat num 
   (setq na (ssname ss x)) 
   (setq lst (entget na))
   (setq lst (subst (cons 41 dms) (assoc 41 lst) lst))
   (setq lst (subst (cons 42 dms) (assoc 42 lst) lst))
   (setq lst (subst (cons 43 dms) (assoc 43 lst) lst))
   (entmod lst) 
   (entupd na) 
   (setq x (+ x 1))
  )
 )
)
(command "attsync" "name" "*")
       (command ".UNDO" "E") 
(setq *error* old_err)
(setvar "CMDECHO" olcmdecho)
(princ)
)

Posted
You know, I have been using this lisp made by David and modified by me, this match selected blocks all selected blocks (normal, attribute, dynamic and annotative) to current dimscale.

 

It's a beauty, but now I realize that some blocks have negative x, y, z scale factor values (mirrored blocks) and I would like to preserve those values because usually the mirror was required for direction and it's necessary to preserve negative values when exist.

 

There are other block scaling routines but those routines use the

(command "scale" eachblockinsertion "insertionpoint" (/ newscale currentscale))

 

and when using those routines, they work until they find a negative value, then the routine stucks with this message

 

Value must be positive and nonzero.

; error: Function cancelled

 

Could there be a way to change each block's x,y,z value but preserving their original value sign (positive or negative)?

 

Anybody knows how?

 

;;; BXY by David Harrington; Modified by Paulo Gil Soto (added annotation scale reset to 1:1)
;;; updates selected blocks x,y and z values to current Dimscale
;;;
;;; Main Program
;;;
(defun c:Bu (/ ss xs ys zs num x na lst editxyz_error olcmdecho old_err) 
(defun editxyz_error (msg) 
 (if (or
   (= msg "Function cancelled")
   (/= msg "quit / exit abort")
  ) 
  (princ (strcat "Error: " msg))
 ) 
 (command ".UNDO" "E" "UNDO" "") 
 (setq *error*  old_err
    old_err  nil
 )
 (setvar "CMDECHO" olcmdecho)
 (princ)
) 
(setq old_err *error* 
   olcmdecho (getvar "CMDECHO")
   *error* editxyz_error
) 
(setvar "CMDECHO" 0)
       (setq dms (getvar "dimscale"))
(command ".UNDO" "BE")  (prompt "\nSelect Blocks to match current dimscale: ")
(cond
 ((setq ss (ssget '((0 . "INSERT"))))
        (command "-objectscale" ss "" "add" "1:1" "" "cannoscale" "1:1") 
  (setq num (sslength ss))
  (setq x 0)
  (repeat num 
   (setq na (ssname ss x)) 
   (setq lst (entget na))
   (setq lst (subst (cons 41 dms) (assoc 41 lst) lst))
   (setq lst (subst (cons 42 dms) (assoc 42 lst) lst))
   (setq lst (subst (cons 43 dms) (assoc 43 lst) lst))
   (entmod lst) 
   (entupd na) 
   (setq x (+ x 1))
  )
 )
)
(command "attsync" "name" "*")
       (command ".UNDO" "E") 
(setq *error* old_err)
(setvar "CMDECHO" olcmdecho)
(princ)
)

 

 

somebody autocalled "awerning" helped me out in this...

check below

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

 

it works, perfect...

 

the bad thing is that I wanted it to use it with attributte blocks, and now I realized it will kinda mirror the attributes or something... so It preserves negative values in selected blocks but kinda mirror text making it unreadable (unless we can read from right to left)

 

These blocks I am trying to scale and preserve are dynamic, so I guess I will make a dynamic option to move the text around instead of mirroring, which is causing the need of preserving negative values... but I guess this is better now than modifying the values to positive,...

 

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

ooouk, I dit it...

 

by adding a flip action to each dynamic block attribute and mask I can avoid the mirroring blocks with attributes... Now I dont have a reason to mirror any of my blocks and can keep all in positive x,y,z values.

 

I started loving dynamic blocks.

Bu-.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...