|
关于惯性矩计算cad2002中运行正常,2004/5/6中运行出错,代码为
Private Sub CommandButton_Click()
UserForm1.Hide
Dim temp(0 To 2) As Double
Dim currUCS As AcadUCS
Dim origin(0 To 2) As Double
Dim Centroid As Variant
Dim momentOflnertia As Variant
Dim sset As AcadSelectionSet 'Define sset as a SelectionSet object
'Set sset to a new selection set namaed SS1 (the name doesn't matter here)
Set sset = ThisDrawing.SelectionSets.Add("SS1")
sset.SelectOnScreen 'Prompt user to selet objects
'save cuurent UCS origin
temp(0) = ThisDrawing.ActiveUCS.origin(0)
temp(1) = ThisDrawing.ActiveUCS.origin(1)
temp(2) = ThisDrawing.ActiveUCS.origin(2)
Dim ent As Object 'Define ent as an object For Each ent In sset
'Loop throught the SelectionSet collection
If ent.EntityName = "AcDbRegion" Then
Centroid = ent.Centroid
'Create a UCS and makes it current
Set currUCS = ThisDrawing.ActiveUCS
origin(0) = Centroid(0): origin(1) = Centroid(1): origin(2) = 0
currUCS.origin = origin
ThisDrawing.ActiveUCS = currUCS
momentOflnertia = ent.momentOflnertia
MsgBox "lx=" & Format(momentOflnetia(0) / 10000, "######.00") & "cm^4: ly=" & Format(momentOflnetia(1) / 10000, "######.00") & "cm^4", , "被选择物体的惯性矩"
currUCS.origin = temp
ThisDrawing.ActiveUCS = currUCS 'restore ActiveUCS origin
End If
Next ent
sset.Delete
UserForm1.Show
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
nijce3ypor3.gif
|
|