Jump to content

getting 3dSolid Box properties using VBA...


Recommended Posts

  • 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

I find the Oriented Bounding Box (OBB) problem quite compelling. It has such widespread applicability that it justifies all the thought it can be given. It also seems to be the type of programming problem that could hinge on the perfect algorithm. I’m not sure, however, if even that would be 100% bulletproof (I think that is why MickD prefers the “data imbued at creation” methodology).

 

Perhaps the biggest problem associated with a commercial OBB offering, then, would be determining at what point is the routine considered successful for any given industry.

 

For my BOM requirements, for instance, the correct dims returned from the part illustrated in post #40 would be nice, though not absolutely necessary. It may even be more helpful for me if that solid were just flagged as indeterminate; it has other factors to consider beyond its length in I-beam.

 

Those realities aside; programmers indulging their intellectual curiosity tend not to be satisfied with semi successful algorithms.

Posted

Luis, that routine is working pretty well . . . . even with solids that are more complex than I would typically be concerned about. It is, however, tripping up one of the solids in the file I attached to post #15 of this thread.

 

It’s interesting because that solid is not particularly complex. Perhaps therein lays a clue as to the type of algorithm you are using.:twisted:

Solid.jpg

Posted
Luis, that routine is working pretty well . . . . even with solids that are more complex than I would typically be concerned about. It is, however, tripping up one of the solids in the file I attached to post #15 of this thread.

 

It’s interesting because that solid is not particularly complex. Perhaps therein lays a clue as to the type of algorithm you are using.:twisted:

 

Hi Sean,

 

I'll have a look.

Posted
Hi Sean,

 

I'll have a look.

 

OK, on a quick look, it appears the issue are the points, if you move that solid to the origin 0,0,0 from any of the bottom base points, you will see that it will output the right data.

 

Since I am just working with points, it is interesting to see, as to why fails if those points are not way to far from the origin, this appears to be an issue with autocad coordinates precision, and something I suffer when wrote my gbpoly program for example - or it can be seen if one use bpoly function with very large coordinates.

 

Will try to fix that - and also the box temp vectors, this needs more work for sure.

Posted
I find the Oriented Bounding Box (OBB) problem quite compelling. It has such widespread applicability that it justifies all the thought it can be given. It also seems to be the type of programming problem that could hinge on the perfect algorithm. I’m not sure, however, if even that would be 100% bulletproof (I think that is why MickD prefers the “data imbued at creation” methodology).

 

Perhaps the biggest problem associated with a commercial OBB offering, then, would be determining at what point is the routine considered successful for any given industry.

 

For my BOM requirements, for instance, the correct dims returned from the part illustrated in post #40 would be nice, though not absolutely necessary. It may even be more helpful for me if that solid were just flagged as indeterminate; it has other factors to consider beyond its length in I-beam.

 

Those realities aside; programmers indulging their intellectual curiosity tend not to be satisfied with semi successful algorithms.

 

My reason to play with this and any other project, it is to learn something new, and also that could help me on possible future projects, that I might end working or even portions of the code.

 

Many of the projects I wrote in the past, are now helping me to solve a lot of my actual tasks for my daily work - much easier.

Posted
Luis, that routine is working pretty well . . . . even with solids that are more complex than I would typically be concerned about. It is, however, tripping up one of the solids in the file I attached to post #15 of this thread.

 

Sean,

 

I was able to did a quick fix and now appears to work for this case in particular - there is now an updated zip uploaded.

 

Still it might fail with other solids - also there is some more work to do on this project.

 

LE!

Posted

still fine in my few tests here ,Just curious LE, what is the principle involved in your code to get the bounding box(in layman's terms please)?

Posted
still fine in my few tests here ,Just curious LE, what is the principle involved in your code to get the bounding box(in layman's terms please)?

 

In one word: Experience

:geek:

 

And yes the project is not complete at all, for now it will put on hold, until I get the chance again to play a little more.

 

LE!

Posted
Experience

 

Good enough LE, hope to get there also someday

  • 3 years later...
Posted
Hello!

The problem is:

When i create a Box, then select it and click right mouse button and select properties menu, the window called Propertoes is displayed. This window have information about the box that is selected such as Length, heigh, width and so on...

So i need to write VB application where i can store this parameters. I need to do this only with Box objects that are free oriented in a ModelSpace.

Thank you for your advices!

 

Sub teste()

'Dim objEnt As Acad3DSolid

Dim varPick As Variant

Dim LL As Variant

Dim UR As Variant

ThisDrawing.Utility.Prompt (vbln & vbln & "Dimentions: " & vbLf)

 

'On Error Resume Next

counter = 0

 

For Each objEnt In ThisDrawing.ModelSpace

If InStr(1, objEnt.EntityName, "3d") > 0 Then

 

objEnt.GetBoundingBox LL, UR

 

dim1 = Math.Round(UR(0) - LL(0), 3)

dim2 = Math.Round(UR(1) - LL(1), 3)

dim3 = Math.Round(UR(2) - LL(2), 3)

 

If (dim1

If (dim2 > dim3) Then

outStr = dim1 & "," & dim2 & "," & dim3

Else

outStr = dim1 & "," & dim3 & "," & dim2

End If

End If

 

If (dim2

If (dim1 > dim3) Then

outStr = dim2 & "," & dim1 & "," & dim3

Else

outStr = dim2 & "," & dim3 & "," & dim1

End If

End If

 

If (dim3

If (dim1 > dim2) Then

outStr = dim3 & "," & dim1 & "," & dim2

Else

outStr = dim3 & "," & dim2 & "," & dim1

End If

End If

 

 

ThisDrawing.Utility.Prompt (outStr & vbLf)

counter = counter + 1

End If

Next

 

ThisDrawing.Utility.Prompt ("Total: " & counter & " 3D objects found." & vbLf)

 

End Sub

Posted
mcampos700, nicely done. Welcome to the forum.

 

seems like this routine only deals with properly oriented 3d solids? is it right?

Posted

That seems to be the case. A good start, though. Anyone attacking this via VBA has to be commended.

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...