Get scale

Kiwi Russ

Usenet Archive
Joined
Jul 24, 2003
Messages
72
Reaction score
0
I would like to determine the scale of a block from an entity list. I have the line below, which takes the x value scale, but I'm sure there is a much better way?
thanks Russ

(setq blkscale (cdr (nth 13 elist)))
 
(setq blkscale (cdr (assoc 41 eList)))

And just to be splitting hairs, your entity is a block reference (INSERT), not a block... :-)
 
Hi Russ,

Given your recent thread, "Convert to ActiveX", why not bite the bulllet now? Consider how much easier coding can be without DXF codes. Closer to plain English, though granted, still geek speak.

;; no error checking for insert selected
(defun c:GetInsertScale ( / ename vobj xscale yscale zscale ) (setq ename (car (entsel "\nSelect block insert: ")) vobj (vlax-ename->vla-object ename) xscale (vlax-get vobj 'XScaleFactor) yscale (vlax-get vobj 'YScaleFactor) zscale (vlax-get vobj 'ZScaleFactor) ) (princ (strcat "\nX scale = " (rtos xscale 2))) (princ (strcat "\nY scale = " (rtos yscale 2))) (princ (strcat "\nZ scale = " (rtos zscale 2))) (princ)
) ;end

Joe Burke
 
I have been following the threads about "Biting the Bullet". My biggest complaint is that the new coding requires 2-4 times as many keystrokes. I write a lot of AutoLISP code and it concerns me that I will have to spend a lot more time just hitting the keys to produce the same code.
 
Kinda like comparing: (rtos xscale 2 4) and (vla-realtostring doc-util xscale 2 4)

It's easy to get carried away with the unnecessary, but very useful to learn and use when needed.

Added to Joe's example some useful and maybe some useless items.

(defun c:GetInsertScale (/ vobj pick-point xscale yscale zscale)
(vl-load-com)

(or *acad-obj*
(setq *acad-obj* (vlax-get-acad-object)))

(or *act-doc*
(setq *act-doc* (vla-get-activedocument *acad-obj*)))

(setq doc-util (vla-get-utility *act-doc*))

(vla-getentity doc-util 'vobj 'pick-point
"\nSelect block insert:")

(cond
((= (vla-get-objectname vobj) "AcDbBlockReference")
;;or use this to check for available properties
;;(proptest vobj (list 'XScaleFactor 'YScaleFactor
'ZScaleFactor))
(setq xscale (vlax-get vobj 'XScaleFactor)
yscale (vlax-get vobj 'YScaleFactor)
zscale (vlax-get vobj 'ZScaleFactor)
)
(princ (strcat "\nX scale = " (vla-realtostring doc-util xscale 2 4))) (princ (strcat "\nY scale = " (rtos yscale 2 4))) (princ (strcat "\nZ scale = " (rtos zscale 2 4))) ) (T (princ "\nInsert not selected! ")) ) (princ)
)

(defun proptest (vla-obj prop-list)
(vl-every '(lambda (x)
(vlax-property-available-p vla-obj x)
)
prop-list
)
)
 
Thanks for the interesting replies guys.
I have one other question---- if I have a dotted pair list of the Block (insert) which I will call "dotpairlist" The list consist of each tag name and the value associated with it. At the moment I have for example dwg name : (setq DwgName (cdr (nth 0 dotpairlist)) But how is it done with Activex? thanks once again Russ
 
Alan,

I'm fairly new to the vlisp ActiveX stuff. I got into LISP a few years ago. Wrote all my stuff using that. Now that I have a (questionable) handle on the vlisp stuff, I'm going back and rewriting the LISP code. Doing so in almost all cases results in fewer lines of code. Not to mention, I don't have to think about DXF codes anymore.

Have you tried it?

Regards
Joe Burke
 
I don't quite follow what you are asking here, Russ. But if it's the block's attributes you are after then you can use something like this (no error checking, just an example):

(defun list_tags ( / obj atts)
(setq obj (vlax-ename->vla-object (car (entsel))))
(setq atts (vlax-safearray->list
(vlax-variant-value
(vla-getattributes obj))))
(foreach x atts
(princ (strcat "\n" (vla-get-tagstring x)))
)
(princ)
)

Jeff
 

Latest threads

Back
Top