Get scale

Discussion in 'AutoCAD' started by Kiwi Russ, Jan 28, 2004.

  1. Kiwi Russ

    Kiwi Russ Guest

    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)))
     
    Kiwi Russ, Jan 28, 2004
    #1
  2. Kiwi Russ

    Rune Wold Guest

    (setq blkscale (cdr (assoc 41 eList)))

    And just to be splitting hairs, your entity is a block reference (INSERT),
    not a block... :)
     
    Rune Wold, Jan 28, 2004
    #2
  3. Kiwi Russ

    Joe Burke Guest

    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
     
    Joe Burke, Jan 28, 2004
    #3
  4. 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.
     
    Alan Henderson, Jan 28, 2004
    #4
  5. 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
    )
    )

    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Jan 28, 2004
    #5
  6. Kiwi Russ

    Kiwi Russ Guest

    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
     
    Kiwi Russ, Jan 29, 2004
    #6
  7. Kiwi Russ

    Joe Burke Guest

    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
     
    Joe Burke, Jan 29, 2004
    #7
  8. Kiwi Russ

    Jeff Mishler Guest

    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
     
    Jeff Mishler, Jan 29, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.