明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1138|回复: 0

AutoCAD 2006 VBA程序参考之----实体分析:质量特性。

[复制链接]
发表于 2007-12-12 17:04:00 | 显示全部楼层 |阅读模式
Analyzing Solids: Mass Properties---实体分析------质量特性
Each 3DSolid object has a number of mass properties you can use for analysis. These properties
include the center of gravity, the total volume of the solid, the radii of gyration, the product of
inertia, and the moment of inertia.
每个3维实体你可以分析三维实体的质量特性,包括质量中心,实体的全容积,回转半径,惯性积,惯性力矩。
The following example displays the mass properties for a selected solid. Try it on one of
the solids you created earlier in the chapter.
这个实例表述选择实体质量特性。
  1. Public Sub TestMassProperties()
  2.   Dim objEnt As Acad3DSolid
  3.   Dim varPick As Variant
  4.   Dim strMassProperties As String
  5.   Dim varProperty As Variant
  6.   Dim intI As Integer
  7.   On Error Resume Next
  8.   '' let user pick a solid
  9.   With ThisDrawing.Utility
  10.     .GetEntity objEnt, varPick, vbCr & "Pick a solid: "
  11.     If Err Then
  12.       MsgBox "That is not an Acad3DSolid"
  13.       Exit Sub
  14.     End If
  15.   End With
  16.   '' format mass properties
  17.   With objEnt
  18.     strMassProperties = "Volume: "
  19.     strMassProperties = strMassProperties & vbCr & " " & .Volume
  20.     strMassProperties = strMassProperties & vbCr & vbCr & _
  21.     "Center Of Gravity: "
  22.     For Each varProperty In .Centroid
  23.       strMassProperties = strMassProperties & vbCr & " " & varProperty
  24.     Next
  25.     strMassProperties = strMassProperties & vbCr & vbCr & _
  26.       "Moment Of Inertia: "
  27.     For Each varProperty In .MomentOfInertia
  28.       strMassProperties = strMassProperties & vbCr & " " & varProperty
  29.     Next
  30.     strMassProperties = strMassProperties & vbCr & vbCr & _
  31.       "Product Of Inertia: "
  32.     For Each varProperty In .ProductOfInertia
  33.       strMassProperties = strMassProperties & vbCr & " " & varProperty
  34.     Next
  35.     strMassProperties = strMassProperties & vbCr & vbCr & "Principal Moments: "
  36.     For Each varProperty In .PrincipalMoments
  37.       strMassProperties = strMassProperties & vbCr & " " & varProperty
  38.     Next
  39.     strMassProperties = strMassProperties & vbCr & vbCr & "Radii Of Gyration: "
  40.     For Each varProperty In .RadiiOfGyration
  41.       strMassProperties = strMassProperties & vbCr & " " & varProperty
  42.     Next
  43.     strMassProperties = strMassProperties & vbCr & vbCr & "Principal Directions: "
  44.     For intI = 0 To UBound(.PrincipalDirections) / 3
  45.       strMassProperties = strMassProperties & vbCr & " (" & _
  46.         .PrincipalDirections((intI - 1) * 3) & ", " & _
  47.         .PrincipalDirections((intI - 1) * 3 + 1) & "," & _
  48.         .PrincipalDirections((intI - 1) * 3 + 2) & ")"
  49.     Next
  50.   End With
  51.   '' highlight entity
  52.   objEnt.Highlight True
  53.   objEnt.Update
  54.   '' display properties
  55.   MsgBox strMassProperties, , "Mass Properties"
  56.   '' dehighlight entity
  57.   objEnt.Highlight False
  58.   objEnt.Update
  59. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 10:30 , Processed in 0.144813 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表