Author Topic: Bounding box  (Read 6581 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
Bounding box
« on: October 09, 2004, 09:45:39 AM »
Is there another way without using "vla" to obtain a bounding box around an entity?

ie: circle, ellipse, spline

Or is it much quicker to use "vla"?

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Bounding box
« Reply #1 on: October 09, 2004, 11:50:40 AM »
IMHO, it is much quicker with ActiveX (vla-,vlax-).....in straight lisp you'd need a lot of math code for anything but the simplest objects....

I mean, even for a line:
Code: [Select]

(setq ent (car (entsel "\nSelect line: "))
      obj (vlax-ename->vla-object ent))
(vlax-invoke-method obj "getboundingbox" 'll 'ur)
(setq ll (vlax-safearray->list ll)
      ur (vlax-safearray->list ur))

 And lisp...
Code: [Select]

(setq ent (car (entsel "\nSelect line: "))
      entlist (entget ent)
      startPt (cdr (assoc 10 entlist))
      endPt (cdr (assoc 11 entlist)))
(setq ll (list (min (car startPt) (car endPt))
      (min (cadr startPt) (cadr endPt))
      (min (caddr startPt) (caddr endPt)))
      ur (list (max (car startPt) (car endPt))
      (max (cadr startPt) (cadr endPt))
      (max (caddr startPt) (caddr endPt)))
      )

whdjr

  • Guest
Bounding box
« Reply #2 on: October 09, 2004, 12:36:42 PM »
I already had this so I used it.
I was curious if anybody had a better way?
Code: [Select]

(defun get-bbox (ent / pnts ll ur)
  (vla-getboundingbox (vlax-ename->vla-object ent) 'll 'ur)
  (setq pnts (mapcar 'vlax-safearray->list (list ll ur))
          pnts (list (list (caar pnts) (cadar pnts))
  (list (caadr pnts) (cadar pnts))
  (list (caadr pnts) (cadadr pnts))
  (list (caar pnts) (cadadr pnts))
                 )
  )
)

Thnaks,

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #3 on: October 09, 2004, 03:20:48 PM »
Better? Quite doubtful, but for fun I just wrote this --

Code: [Select]
(defun GetBoundingBox ( ename / data pt1 pt2 )
    ;;
    ;;  Michael Puckett 2004/10/09
    ;;
    ;;  Minimalist approach, no error handling;
    ;;  ensure you call it with a valid entity,
    ;;  like one that actually has bounds, lest
    ;;  it crash.
    ;;
    (vlax-invoke-method
        (vlax-ename->vla-object ename)
       'GetBoundingBox
       'pt1
       'pt2
    )
    (setq data
        (list
            (mapcar
                'vlax-safearray->list
                (list pt1 pt2)
            )
        )
    )
    (mapcar
       '(lambda (funcs)
            (mapcar
               '(lambda (func) (apply func data))
                funcs
            )
        )    
       '((caar cadar)(caadr cadar)(caadr cadadr)(caar cadadr))
    )
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

whdjr

  • Guest
Bounding box
« Reply #4 on: October 11, 2004, 09:13:58 AM »
Thanks guys, I appreciate the comments.

The main reason I was asking was because my program uses no activeX technology except this part.  I was just wondering if there was a better way not to mix autolisp with activeX if I didn't need too?

Just a thought.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #5 on: October 11, 2004, 09:20:41 AM »
Unless you're using AutoCAD versions < 2000 I don't see the benefit. Please enlighten. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

whdjr

  • Guest
Bounding box
« Reply #6 on: October 11, 2004, 09:47:11 AM »
I just don't like to mix pure autolisp with the "vla" commands if I don't have to.  That was all.  Just my preference.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #7 on: October 11, 2004, 10:14:55 AM »
By "Pure AutoLISP" (let's call it vanilla) do you mean entget, entmod etc.?

My opinion: for no real reason you're denying yourself the benefits of functionality not offered in vanilla lisp, or methods that are more convenient | efficient.

I was relatively late to start using extendo lisp because our company as a whole lags behind the leading edge (if we start a project with version x we finish the project with version x; many projects span 2 or 3 years). Having used extendo lisp now for a couple years I wouldn't go back.

Having said that some times vanilla lisp techniques are still required, so I don't think you will ever see any medium | large lisp applications that are pure vanilla or pure extendo.

Anyway, take it or leave it, just sharing my thoughts on the topic.

Have a good day.

Cheers. :)

Edit: I see you posting vla-* code in other threads so ignore the evangelical bits above.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Bounding box
« Reply #8 on: October 11, 2004, 11:06:35 AM »
Quote from: MP
many projects span 2 or 3 years

Programming projects?
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #9 on: October 11, 2004, 11:19:53 AM »
Engineering.

Some programming projects are ongoing, insomuch as they are updated to reflect current engineering requirements. This means some (programming) projects may span a couple years (in a per se kind of way)

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

whdjr

  • Guest
Bounding box
« Reply #10 on: October 11, 2004, 11:27:30 AM »
Quote from: MP
Edit: I see you posting vla-* code in other threads so ignore the evangelical bits above.

Quote from: whdjr
I just don't like to mix pure autolisp with the "vla" commands if I don't have to.

Don't get me wrong I love to use vla commands.  My comment was concerning writing a whole program without using vla and then at the end tagging one subr to accomplish a certain task using vla.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Bounding box
« Reply #11 on: October 11, 2004, 11:33:58 AM »
Fascinating stuff there MP, sounds like you have a nice job.  Let me ask you this if I may. When your company gets a new project are the programmers involved from the start?

My apologizes for hijacking this thread.
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #12 on: October 11, 2004, 11:36:30 AM »
Sometimes. :roll:

Actually it's a lot better now, but in the "old" days ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Bounding box
« Reply #13 on: October 12, 2004, 09:45:19 AM »
The "ActiveX" you refer to is basicly nothing more then an extension of sorts for the AutoLisp language. (Basicly all your doing when you use those "vla..." functions is calling a C++ dll to do some work for you.) I see no reason why the two cant be mixed. I see no other reason besides if you were to port your apps for Intellacad or Acad ver 14 for NOT mixing the two.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Bounding box
« Reply #14 on: October 12, 2004, 10:43:33 AM »
There used to be (pre 2004) alot of issues when mixing ActiveX with certain entity handling functions. It was a sure way to crash VisualLISP.
My short term memory doesn't allow for detailing the problems but they were (and are, for those who are still using earlier versions) very real.

Seeing that Will is using A2K, my recommendation would be not to mix direct ActiveX calls and entity handling functions like ENTMAKE, ENTMOD and ENTGET.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Bounding box
« Reply #15 on: October 12, 2004, 10:50:48 AM »
Note to self: Mixing ActiveX with certain entity handling functions, "a sure way to crash VisualLISP" (< A2K4).

I have not observed this despite writing buckets of mixed code but I'll watch for it. Thanks Stig.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

SMadsen

  • Guest
Bounding box
« Reply #16 on: October 12, 2004, 11:43:29 AM »
Really? I can't count the times I've gotten access violations when using mixed code.

I've just spent half an hour looking through some text documents for a post from which I for the first time was able to reproduce the exceptions. But to no avail. Oh well. Just like making mayonaise: mix until it doesn't split. Or until it splits? Can't even remember that one (must be getting old!).

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Bounding box
« Reply #17 on: October 12, 2004, 12:08:13 PM »
I too have had problems mixing the two. Only it wasn't me doing the mixing. I wrote an app that used all entmake/entmod, it only crashed acad when it ran on another machine using VBA/Vlisp. I re-wrote the code to use all vla-add- and the problem went away.
TheSwamp.org  (serving the CAD community since 2003)

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Bounding box
« Reply #18 on: October 12, 2004, 12:55:30 PM »
Now wait a min! The "entmake", "entmod"...  functionality was "replaced" so there should be no need to use the old. Im refering to the stuff that is still "suported by future version of acad".

...Im not trying to start another ELOCK violation discussion here. (I prolly should have been more specific, but i didnt think my comment was gonna be taken so litterly. )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org