Author Topic: Few GetBoundingBox issues  (Read 2330 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Few GetBoundingBox issues
« 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))))
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Few GetBoundingBox issues
« Reply #1 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)))

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Few GetBoundingBox issues
« Reply #2 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)))))

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Few GetBoundingBox issues
« Reply #3 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:
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg