Bounding Box

Bounding Box

Anonymous
Not applicable
2,713 Views
6 Replies
Message 1 of 7

Bounding Box

Anonymous
Not applicable
I'm sure that this is a redundant subject but I really need help. By using the bounding box, I would like to determine the length, width, and height of a part. I found this code::: But I'm having a difficult time to set this code in place. Can anyone help me with this? Is there an easier alternative?

Thanks,

Hiram

Public Sub ShowRange()
' Get the active document. This assumes it is a part document.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

Dim oBox As Box
Set oBox = oPartDoc.ComponentDefinition.SurfaceBodies.Item(1).RangeBox

Dim strResult As String
strResult = "Part Range Size:" & vbCrLf
strResult = strResult & " X Size: " & Format(oBox.MaxPoint.X -
oBox.MinPoint.X, "0.000000") & " cm" & vbCrLf
strResult = strResult & " Y Size: " & Format(oBox.MaxPoint.Y -
oBox.MinPoint.Y, "0.000000") & " cm" & vbCrLf
strResult = strResult & " Z Size: " & Format(oBox.MaxPoint.Z -
oBox.MinPoint.Z, "0.000000") & " cm"
MsgBox strResult
End Sub
0 Likes
2,714 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
On Mon, 17 Oct 2005 14:40:38 +0000, hnorwood wrote:

> I'm sure that this is a redundant subject but I really need help. By
> using the bounding box, I would like to determine the length, width, and
> height of a part. I found this code::: But I'm having a difficult time
> to set this code in place. Can anyone help me with this? Is there an
> easier alternative?

The code works fine... what's the problem?
0 Likes
Message 3 of 7

Anonymous
Not applicable
I get an error message regarding the syntax at Public Sub ShowRange(). I think I'm probably doing something wrong. Should I try to copy and paste in the VB Editor? What steps are you taking?
0 Likes
Message 4 of 7

Anonymous
Not applicable
Where are you pasting this code now to give an error message at Public Sub
ShowRange()?
0 Likes
Message 5 of 7

Anonymous
Not applicable
Tools>macros>visual basic editor. I started a new project and I pasted the code in module 1. I made a mistake by saying that it was in Public Sub Showrange (). It was actually in

strResult = strResult & " X Size: " & Format(oBox.MaxPoint.X -
oBox.MinPoint.X, "0.000000") & " cm" & vbCrLf
strResult = strResult & " Y Size: " & Format(oBox.MaxPoint.Y -
oBox.MinPoint.Y, "0.000000") & " cm" & vbCrLf
strResult = strResult & " Z Size: " & Format(oBox.MaxPoint.Z -
oBox.MinPoint.Z, "0.000000") & " cm"

The above was highlighted red due to statement overlapping. I fix that problem now the code runs until Set oPartDoc = ThisApplication.ActiveDocument

The error that I get is run-time error 13 type mismatch
0 Likes
Message 6 of 7

Anonymous
Not applicable
On Tue, 18 Oct 2005 16:47:51 +0000, hnorwood wrote:

> I fix that problem now the code runs until Set oPartDoc =
> ThisApplication.ActiveDocument The error that I get is run-time error 13
> type mismatch

Then your active document in Inventor is not a part...
0 Likes
Message 7 of 7

Anonymous
Not applicable

What about getting sizes of assies bounding box? Any ideas?

0 Likes