TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Grrr1337 on November 24, 2016, 03:21:38 PM

Title: Few GetBoundingBox issues
Post by: Grrr1337 on November 24, 2016, 03:21:38 PM
Hi guys, I've got a few(2) questions:

1. Why this work
Code: [Select]
(vla-GetBoundingBox o 'll 'ur)
But these don't
Code: [Select]
(vlax-invoke-method o 'GetBoundingBox 'll 'ur)
(vlax-invoke o 'GetBoundingBox 'll 'ur)


Getting the BBox's centroid
2. Is there a way to get rid of the Lst quote,
Code: [Select]
(setq Lst (mapcar 'vlax-safearray->list (list ll ur)))
(setq cen (mapcar '(lambda (a b) (/ (+ a b) 2.)) (car Lst) (cadr Lst)))
Without using this (obviously):
Code: [Select]
(setq cen
(mapcar '(lambda (a b) (/ (+ a b) 2.))
(car (mapcar 'vlax-safearray->list (list ll ur)))
(cadr (mapcar 'vlax-safearray->list (list ll ur)))
)
)

With something like:
Code: [Select]
(setq cen (apply '(lambda (x) ????? ) (mapcar 'vlax-safearray->list (list ll ur))))
Title: Re: Few GetBoundingBox issues
Post by: roy_043 on November 24, 2016, 03:39:34 PM
2.:
Code - Auto/Visual Lisp: [Select]
  1. (setq cen (mapcar '(lambda (a b) (/ (+ a b) 2.)) (vlax-safearray->list ll) (vlax-safearray->list ur)))
Title: Re: Few GetBoundingBox issues
Post by: Lee Mac on November 24, 2016, 04:34:16 PM
Alternatively:
Code - Auto/Visual Lisp: [Select]
  1. (setq cen (apply 'mapcar (cons '(lambda (a b) (/ (+ a b) 2.)) (mapcar 'vlax-safearray->list (list ll ur)))))
Title: Re: Few GetBoundingBox issues
Post by: Grrr1337 on November 24, 2016, 04:46:14 PM
Thanks guys!
I've used before Roy's suggestion (Its my fault not to mention it), so tried to figure out something like Lee's (apply with mapcar 'vlax-safearray->list combo).

About #1 I suspect that when you provide quotes that have to be set by visual lisp after invoking the method (like GetBoundingBox), it will use safearrays/variants and not vanilla lisp type values (in this case point of list type was expected). Atleast thats what I think for now  :thinking: