乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 11|回复: 0

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

[复制链接]

120

主题

326

帖子

7

银币

中流砥柱

Rank: 25

铜币
806
发表于 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
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-5 13:06 , Processed in 0.548028 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表