Author Topic: nested blocks inside another block question  (Read 1620 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
nested blocks inside another block question
« on: July 09, 2014, 10:32:21 AM »
I found this code here:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/How-to-get-name-of-a-nested-block/td-p/4656629

I would like to understand this line:

Code: [Select]
(while (/=(type(setq e (car(last(nentsel "\nSelect any BLOCK to edit: "))))) 'ENAME))
Why does 'ENAME have the '

Thanks

ronjonp

  • Needs a day job
  • Posts: 7529
Re: nested blocks inside another block question
« Reply #1 on: July 09, 2014, 12:02:20 PM »
It's so 'ename' is not evaluated. It will look at it as a symbol. I was going to go further in depth but Lee has it covered.  8)
http://www.lee-mac.com/quote.html


And straight from the help: http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-506C9CC8-B0BD-4A4C-B4C2-006750504509

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: nested blocks inside another block question
« Reply #2 on: July 09, 2014, 12:41:08 PM »
So it reads 'ENAME as ENAME not a (setq variable) assigned to ENAME

ENAME is a datatype retrieved by the (type function) the 'ENAME is so AutoLisp sees this as a symbol and not a variable.

When reading the (type) function from the help, I am not use to seeing (setq) written this way in a straight line:
Code: [Select]
(setq a 123 r 3.45 s "Hello!" x '(a b c))
So I did not follow that (setq) was assigning (a) as "1 2 3" and (r) as "3.45" and so on....  Now the help example make more sense.

I see LeeMac's explanation of the bounding box:  can you help me understand 'P1 and 'P2 and how they supply the (setq P1) and (setq P2) with a list?  Because the "vlax-safearray->list P1" the P1 does not follow up with 'P1, I am a little lost in how it knows to use 'P1 in P1.

Code: [Select]
(setq obj (vlax-ename->vla-object e))
  (vla-getboundingbox OBJ 'P1 'P2)
  (setq P1(vlax-safearray->list P1))
  (setq P2(vlax-safearray->list P2))
  (command "zoom" "w" p1 p2)

Thanks

LE3

  • Guest
Re: nested blocks inside another block question
« Reply #3 on: July 09, 2014, 01:07:33 PM »
^
Many of the activex extensions can be access via APROPOS, you can right-click on the desired function name and select Apropos Window... or highlight the function or simple place the cursor on the function and click on the (A) apropos button, then click on the ? help function, to open the help area for the function name usage. This has been since the days of Vital-Lisp - BTW.

HTH

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: nested blocks inside another block question
« Reply #4 on: July 10, 2014, 01:31:04 PM »
I was going to go further in depth but Lee has it covered.  8)
http://www.lee-mac.com/quote.html

Many thanks for the link Ron  :-)

So it reads 'ENAME as ENAME not a (setq variable) assigned to ENAME

Yes, by quoting the symbol ENAME, it is interpreted as a symbol, rather than evaluated to yield any value it may hold.

ENAME is a datatype retrieved by the (type function) the 'ENAME is so AutoLisp sees this as a symbol and not a variable.

Yes, the type function returns a symbol which is then compared with the symbol ENAME to test for equality.

I see LeeMac's explanation of the bounding box:  can you help me understand 'P1 and 'P2 and how they supply the (setq P1) and (setq P2) with a list?  Because the "vlax-safearray->list P1" the P1 does not follow up with 'P1, I am a little lost in how it knows to use 'P1 in P1.

The symbols supplied to the getboundingbox method are the symbols that will hold the output data generated by this method; such symbols are quoted to ensure that the symbol itself is passed to the method, and not evaluated to yield any value that the symbol may already hold.

Following evaluation of the getboundingbox method, the output symbols may be viewed simply as additional local variables, which could have been defined using a simple setq expression. Therefore, when passed to the vlax-safearray->list function, the symbols are supplied unquoted so that they are evaluated to yield the values they point to.

As an aside, you can define your own functions which will accept quoted symbols in the same manner as the getboundingbox method, e.g.:

Code: [Select]
(defun foo ( var1 var2 var3 )
    (set var1 123)
    (set var2 "abc")
    (set var3 '(1.0 2.0 3.0))
    nil
)
Code: [Select]
_$ (foo 'a 'b 'c)
nil
_$ a
123
_$ b
"abc"
_$ c
(1.0 2.0 3.0)

I plan to add this extra information to the tutorial at some point.

I hope this explanation is clear.

Lee