TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Pad on November 24, 2009, 05:26:22 AM

Title: block scale
Post by: Pad on November 24, 2009, 05:26:22 AM
Hello,

What I am looking for is a lisp which will report the scale of one particular block within a drawing.
The lisp routine below reports the scale of all blocks within a drawing, I'd like to know how to modify it so that it just reports the scale of single a block called 'PT'.
This block will be in the drawing multiple times but all would be at the same scale.

Thanks
Pads

Code: [Select]
;;-DISCLAIMER-

;;In no event shall Moss Designs be held liable to anyone for special, collateral, incidental, or consequential damages in connection with
;;or arising out of use of this product.  The sole and exclusive liability to Moss Designs shall not exceed the purchase price of the product.


;;Use of the software has been provided under a Software License Agreement.

;;Information described in this software is furnished for information purposes only, is subject to change without notice, and should not be
;;construed as a commitment by Moss Designs.  Moss Designs assumes no responsibility or liability for any errors or inaccuracies
;;that may appear in this software.

;;The software contains valuable trade secrets and proprietary information and is protected by United States copyright laws and copyright laws
;;of other countries.  Unauthorized use of the software or its documentation can result in civil damages and criminal prosecution.
;;Ver 1.0
;;November 12, 1999
;;Moss Designs
;;www.mossdesigns.com
;;(408) 231-9863
;;21951 Bear Creek Way
;;Los Gatos, CA 95033
;;Contact Elise Moss, Moss Designs
;;elise_moss@techie.com
;;if you have any questions or problems with this software
;;*****************************************************************************************************************************
;;this software lists the blocks in a drawing and their scales

(defun c:bsclist(/)
  (setq ssblocks (ssget "X" '((0 . "INSERT"))))
  (setq i 0); initialize counter
  (setq ssl (sslength ssblocks))
  (while (< i ssl)
   (progn
    (setq en (ssname ssblocks i))
    (setq el (entget en))
    (setq insert-name (cdr (assoc 2 el)))
    (setq xsc (cdr (assoc 41 el)))
    (setq ysc (cdr (assoc 42 el)))
    (setq line (strcat "BLOCKNAME: " insert-name "  X-SCALE: " (rtos xsc) "  Y-SCALE: " (rtos ysc)))
    (princ line)
    (princ "\n")
    (setq i (+ 1 i))
  ));end while
  (princ)
);end defun
(princ "\nType 'bsclist' to list blocks and their scales")
Title: Re: block scale
Post by: Kerry on November 24, 2009, 05:32:14 AM

Quote
Unauthorized use of the software or its documentation can result in civil damages and criminal prosecution.
Title: Re: block scale
Post by: Pad on November 24, 2009, 05:56:40 AM
Well its free to download from their website  http://www.mossdesigns.com/downloads.htm  BSCLIST.LSP
Surely if they make it freely available, then we are authorised to use it?!

If that's not the case, then forget that lisp.  Do you know how I could find the 'PT' block scale using lisp?
Thanks

Title: Re: block scale
Post by: DEVITG on November 24, 2009, 06:58:40 AM

(setq origin-block (ssname (ssget ":S"  '( ( 0 . "insert")( 2 . "PT")))0))

(setq origin-block-x-scale (cdr (assoc 41 (entget origin-block))))
Title: Re: block scale
Post by: Pad on November 24, 2009, 07:11:08 AM
thank you Devitg  :-)
Title: Re: block scale
Post by: Kerry on November 24, 2009, 07:59:11 AM
Well its free to download from their website  http://www.mossdesigns.com/downloads.htm  BSCLIST.LSP
Surely if they make it freely available, then we are authorised to use it?!
< .. >

OK, Thanks.

Seems a weird agreement/condition statement under those circumstances ..

I will make no comment regarding the quality of the code other than that it seems to be a little immature to require that sort header.
Title: Re: block scale
Post by: Lee Mac on November 24, 2009, 08:02:18 AM
Well its free to download from their website  http://www.mossdesigns.com/downloads.htm  BSCLIST.LSP
Surely if they make it freely available, then we are authorised to use it?!
< .. >

OK, Thanks.

Seems a weird agreement/condition statement under those circumstances ..

I will make no comment regarding the quality of the code other than that it seems to be a little immature to require that sort header.

I second that .
Title: Re: block scale
Post by: Pad on November 24, 2009, 08:07:15 AM
fair enough.
Cheers
Title: Re: block scale
Post by: alanjt on November 24, 2009, 08:26:05 AM
Well its free to download from their website  http://www.mossdesigns.com/downloads.htm  BSCLIST.LSP
Surely if they make it freely available, then we are authorised to use it?!
< .. >

OK, Thanks.

Seems a weird agreement/condition statement under those circumstances ..

I will make no comment regarding the quality of the code other than that it seems to be a little immature to require that sort header.

I second that .

It's like holding your pinkie up when you drink. It doesn't do anything, it just makes you feel fancy.
Title: Re: block scale
Post by: mjfarrell on November 24, 2009, 08:59:43 AM
I am sure that if you had asked Elise Moss would have modified that lisp code for you, and probably included it in her next Newsletter.
Title: Re: block scale
Post by: Keith™ on November 24, 2009, 09:00:12 AM
This will tell you the X, Y and Z scale

Code: [Select]
(defun C:GScale()
  (mapcar '(lambda (X) (cdr(assoc X(entget (ssname (ssget "x" '((0 . "INSERT")(2 . "PT")))0)))))
          '(41 42 43)
  )
)
Title: Re: block scale
Post by: Pad on November 24, 2009, 10:16:24 AM
I have emailed her, its was bounced back as undeliverable.
Jobs done now, thanks for every bodies input.
Title: Re: block scale
Post by: mjfarrell on November 24, 2009, 12:08:33 PM
I have emailed her, its was bounced back as undeliverable.
Jobs done now, thanks for every bodies input.


try another mail here: Elise Moss <elise_moss@mossdesigns.com>
and let me know if it also bounces back, so I can let her know she has an email issue she might not be aware of.
Title: Re: block scale
Post by: Pad on November 24, 2009, 01:07:15 PM
Its all resolved so I don't plan on pursuing it any further.
This is the email I used (which was contained within the lisp) elise_moss@techie.com, the lisp is quite old so maybe this email is now redundant.
Title: Re: block scale
Post by: CAB on November 24, 2009, 01:32:33 PM
If not all the same scale.
Code: [Select]
(defun C:GScale(/ sc)
  (mapcar
    (function
      (lambda (x / elst)
         (setq elst (entget x)
               sc (cons (list (cdr (assoc 41 elst))
                              (cdr (assoc 42 elst))
                              (cdr (assoc 43 elst))) sc))
      ))
    (mapcar 'cadr (ssnamex (ssget "x" '((0 . "INSERT")(2 . "PT")))))
  )
  (while (setq itm (car sc))
    (setq sc (cdr sc))
    (if (not (vl-position itm sc))
      (princ (strcat "\nX-scale: " (vl-princ-to-string (car itm))
                     "  Y-scale: " (vl-princ-to-string (cadr itm))
                     "  Z-scale: " (vl-princ-to-string (caddr itm))))
    )
  )
  (princ)
)

Edited code as it had my block name. :)