关于惯性矩计算cad2002中运行正常,2004/5/6中运行出错
关于惯性矩计算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
第二次运行时出现另一行错误
很多键入错误,主要是momentOfInertia错了
这段程序在2002也不运行正常,问问题应该说实话!
alin发表于2005-9-29 21:45:00
我把dvb文件传上来,alin能否帮看看?
问题应该不在版本,是UCS的问题,凑合用着吧...
非常感谢!
页:
[1]