Jump to content

getting 3dSolid Box properties using VBA...


Recommended Posts

Posted
My full name is Sean Tessier. I use the SEANT concatenation because it looks like it should be pronounced “Saint”. That should gain me instant credibility. :)

 

Just kidding.

 

I think that routine will handle any type extrusion with the appropriate pick point. The algorithm will likely require some modification to handle higher quantity selection sets.

 

Given that AutoCAD programmers are typically the “Up for the Challenge” type of individual, these threads may have recruited a few more participants into this particular theme.

 

Hi Sean,

Saint - that bring me back to a tv serie that I watch some moons ago! :)

 

Yes the original intention (from the master MickD on that forum) was to extract the OBB without doing any transformation or ucs alignment, etc.

 

Since I am new here, have no idea how many programmers normally frequent here, if I do have time (as mentioned before) will try to participate, on the OBB Engine that I was working - I think I was very closed (the project is basically pure C++ and little ARX)

 

 

Thanks!

Luis.

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

  • LEsq

    19

  • SEANT

    15

  • wizman

    6

  • Lee Mac

    6

Top Posters In This Topic

Posted Images

Posted
Yes the original intention (from the master MickD on that forum) was to extract the OBB without doing any transformation or ucs alignment, etc.

 

Since I am new here, have no idea how many programmers normally frequent here, if I do have time (as mentioned before) will try to participate, on the OBB Engine that I was working - I think I was very closed (the project is basically pure C++ and little ARX)

 

I'm sure you'll recognise a few names here from over at theSwamp (alanjt, SeanT, me!, CAB, fixo etc), but imo this is predominantly a CAD forum, and there are far more requests here than programming discussions/people trying to learn.

 

PS> MickD is a genius.

Posted
I'm sure you'll recognise a few names here from over at theSwamp (alanjt, SeanT, me!, CAB, fixo etc), but imo this is predominantly a CAD forum, and there are far more requests here than programming discussions/people trying to learn.

 

PS> MickD is a genius.

 

Yes... Noticed all that.

 

And yes I agree with your PS>...

 

Thank you sir.

Posted

I vaguely remember “The Saint” TV series on reruns. Roger Moore as Simon Templar, driving around in a Volvo P1800 . . . . I recall it was quite entertaining. That is certainly going back a way: Pretty soon a séance will be required to talk to anyone who watched that series’ first run.

 

I tend to agree with all the sentiments of the previous few posts, certainly about MickD, and even about the general level of programming discussion on this forum. I hope, however, that our perception about that level isn’t considered derogatory. I think this forum (all the experienced programmers participating) does the best job of generating enthusiasm in the next generation of coders.

 

I consider myself part of a “next generation” when talking about C++ and ARX. It is nice to see Luis and Daniel here to develop some Lower Level Programming excitement. Perhaps MickD and some of the other pioneers (dare I say Tony Tanzillo) will eventually become members.

Posted
It is nice to see Luis and Daniel here to develop some Lower Level Programming excitement. Perhaps MickD and some of the other pioneers (dare I say Tony Tanzillo) will eventually become members.

 

I agree with you there :)

Posted
I vaguely remember “The Saint” TV series on reruns. Roger Moore as Simon Templar, driving around in a Volvo P1800 . . . . I recall it was quite entertaining. That is certainly going back a way: Pretty soon a séance will be required to talk to anyone who watched that series’ first run.

 

I tend to agree with all the sentiments of the previous few posts, certainly about MickD, and even about the general level of programming discussion on this forum. I hope, however, that our perception about that level isn’t considered derogatory. I think this forum (all the experienced programmers participating) does the best job of generating enthusiasm in the next generation of coders.

 

I consider myself part of a “next generation” when talking about C++ and ARX. It is nice to see Luis and Daniel here to develop some Lower Level Programming excitement. Perhaps MickD and some of the other pioneers (dare I say Tony Tanzillo) will eventually become members.

 

=> I watched that TV show back on 1972 :o

 

=> If I have the chance, I will try to help.

 

=> Tony is way on the top.

 

=> I am a programmer by casualty, doing my hobby and now from my home office (well here my wife and two kids of 20 and 18 don't like the idea, have now about a year so far like this, comming after spending 37 years on my Architecture profession) :D

Posted

I think that routine will handle any type extrusion with the appropriate pick point. The algorithm will likely require some modification to handle higher quantity selection sets.

 

There was a lisp routine similar to the one wizman did, by Gile - not 100% sure - noticed that he is a member here too.

Posted

That's a good call Seant for asking other experienced programmers to visit here. all of us members are eager to have their support. It's a gateway for learning lisp and other programming languages.

 

 

Happy New Year LE, May i ask for the link on Gile's Solution? Thanks

Posted

Happy New Year LE, May i ask for the link on Gile's Solution? Thanks

 

Don't have a link - it was at the adesk customization ng - or maybe was from Doug Broad, not sure, sorry (will try to do a search).

 

Maybe Gile, end up seeing this thread...

 

Happy new year to you too!

 

Regards,

Luis

Posted

Thank you LE for the link, i am a learner of gile's works. let's wait for him to come to this thread to see how he will approach the object oriented bounding box of a solid to get the L,W & H. Running his code without aligning ucs on a rotated 3d box results the picture below:

box.JPG

Posted
=> I watched that TV show back on 1972 :o

 

=> If I have the chance, I will try to help.

 

=> Tony is way on the top.

 

=> I am a programmer by casualty, doing my hobby and now from my home office (well here my wife and two kids of 20 and 18 don't like the idea, have now about a year so far like this, comming after spending 37 years on my Architecture profession) :D

 

It seems obvious that the best software comes from individuals with experience in both programming and the target dicipline.

 

P.S. Didn't mean to imply you have "one foot in the grave". That 1972 running of The Saint series (First run was 1962) is probably when I watched it.

Posted
It seems obvious that the best software comes from individuals with experience in both programming and the target dicipline

 

I would agree with you there Sean, I very often wonder whether my programs will hit the mark, with only just under a year's experience in the process engineering field.

Posted

P.S. Didn't mean to imply you have "one foot in the grave". That 1972 running of The Saint series (First run was 1962) is probably when I watched it.

 

I know...

8)

Posted
I would agree with you there Sean, I very often wonder whether my programs will hit the mark, with only just under a year's experience in the process engineering field.

 

For what I have seen (but not tested any of your routines), you have the touch, and also smart.

 

Go the C# or C++ route (or look what other languages are out there)

 

All in case you end up some day never knows working as a programmer or open your own bussiness... And get paid of your efforts.

 

It will be good idea to know how many offices on a poll (arch, eng, mech, etc) have people doing customizations for their production and are getting paid for doing just that.

Posted

Hi and happy new year to all...

 

Thanks for all compliments, but, I too, do learn from you...

 

This task is quite difficult to make a safe routine, but here's a quick and dirty which try to align UCS to a box face.

It won't work if the selected solid pickpoint isn't on a plane face.

 

(defun c:boxdim    (/ ent obj minPt maxPt)
 (vl-load-com)
 (if (and (setq ent (entsel "\nSelect a box"))
      (setq obj (vlax-ename->vla-object (car ent)))
      (= (vla-get-ObjectName obj) "AcDb3dSolid")
     )
   (if    (vl-catch-all-error-p
     (vl-catch-all-apply
       '(lambda ()
          (vl-cmdf "_.ucs" "_face" (cadr ent) "")
        )
     )
   )
     (princ "\nNot able to get this solid dimensions")
     (progn
   (vla-TransformBy obj (UCS2WCSMatrix))
   (vla-getBoundingBox obj 'minPt 'maxPt)
   (vla-TransformBy obj (WCS2UCSMatrix))
   (vl-cmdf "_.ucs" "_previous")
   (setq minPt (vlax-safearray->list minPt)
         maxPt (vlax-safearray->list maxPt)
   )
   (princ (strcat "\nSolid dimensions : "
              (rtos (- (car maxpt) (car minPt)))
              " "
              (rtos (- (cadr maxpt) (cadr minPt)))
              " "
              (rtos (- (caddr maxpt) (caddr minPt)))
          )
   )
     )
   )
   (princ "\nIncorrect entity")
 )
 (princ)
)

;; Doug C. Broad, Jr.
;; can be used with vla-transformby to
;; transform objects from the UCS to the WCS
(defun UCS2WCSMatrix ()
 (vlax-tmatrix
   (append
     (mapcar
   '(lambda (vector origin)
      (append (trans vector 1 0 t) (list origin))
    )
   (list '(1 0 0) '(0 1 0) '(0 0 1))
   (trans '(0 0 0) 0 1)
     )
     (list '(0 0 0 1))
   )
 )
)
;; transform objects from the WCS to the UCS
(defun WCS2UCSMatrix ()
 (vlax-tmatrix
   (append
     (mapcar
   '(lambda (vector origin)
      (append (trans vector 0 1 t) (list origin))
    )
   (list '(1 0 0) '(0 1 0) '(0 0 1))
   (trans '(0 0 0) 1 0)
     )
     (list '(0 0 0 1))
   )
 )
)

Posted
For what I have seen (but not tested any of your routines), you have the touch, and also smart.

 

Thanks Luis :)

 

Go the C# or C++ route (or look what other languages are out there)

 

I have read most of the basic sytax of C/C++, but haven't really delved into it too deeply - as you may have seen some of my beginner style threads in the C forum over at theSwamp.

 

It will be good idea to know how many offices on a poll (arch, eng, mech, etc) have people doing customizations for their production and are getting paid for doing just that.

 

I would be interested to see that - but I very much doubt there are many employed to do such... :unsure:

Posted
I would agree with you there Sean, I very often wonder whether my programs will hit the mark, with only just under a year's experience in the process engineering field.

 

 

Lee, amazing thing is you're making the hits and with your math knowledge makes you superb.

 

 

This task is quite difficult to make a safe routine, but here's a quick and dirty which try to align UCS to a box face.

It won't work if the selected solid pickpoint isn't on a plane face.

Thank you gile for your response, good code. The plane's face is the restriction at a lisp solution, i agree, like a cylinder or a sphere which have curved surfaces and with aligning ucs to a face has unpredictable direction.
Posted

OK, was just able to play with this old project, let see if someone will be willing to give it a try - it is an ARX file for AutoCAD 2007 to 2009 only.

 

The command name is OBB.

 

This OBB algorithm: Does not change or align anything it simple will try to calculate the oriented bounding box and return the dimensions.

 

Notes:

1. OBB.ARX it is provided AS-IS - use it at your own risk!

2. Run the testing on not working drawings!

3. Or make sure to save a backup first!

4. It is a debug version and not fully tested.

5. This version - does not work on a Cylinder.

6. Expect crashes.

 

Load the attached arx file and once the command it is called just select a 3D solid - and if it is successful it will print on the command the dimensions.

 

Command: OBB

Select solid: Specify opposite corner:

***3DSolid dimensions: L=1739.7404 W=1198.0539 H=1198.0539***

 

Comments are welcome.

 

Thank you for your trust,

Luis.

Obb.zip

Posted

Did some update to the project and added a feature to show the oriented bounding box (using graphic vectors - see the attached image).

 

Still sphere, cones, and cylinders are not supported and all the previous notes applies too.

 

LE!

0000.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...