Re: 密度定義の仕方 ( No.1 ) |
- 日時: 2005/03/24 10:37
- 名前: mmy
| 「分銅型のアイコンを選択→bodyを選択」で開く「慣性を測定」のダイアログで 「密度の設定」は、「特性」>「密度」の入力ボックスの数値を変えているのだと思います。 (他の入力ボックスはグレーアウトしていて入力できませんよね?)
下のツールバーに添付図のアイコン(マテリアルを適用)がありませんか? これをクリックして適当に(パーツ)ボディに適用してみて下さい。 例えば、アルミニウムを適用したとしますね。 ツリーの「(パーツ)ボディ」の下に「アルミニウム」が追加されていると思います。 この「アルミニウム」アイコンを右クリックして「アルミニウムオブジェクト」>「定義」で プロパティを開き、「解析」タブで「密度」の値を適当に変えてから「分銅型のアイコン」を クリックしてみて下さい。変更した値が反映されていると思います。 |
|
Re: 密度定義の仕方 ( No.2 ) |
- 日時: 2006/05/29 12:08
- 名前: takeuchi
| 例えば重さが分かっていて比重が分からないもののモデリング時、うちの運用では比重を好きなように変更できるマテリアルを一つ用意してあります。
そのマテリアルを自動で付加し、比重を計算するマクロを以下に書きます。 (うちの運用上、D/L Name環境ですので、パス指定がそのようになっています。)
下記を参考に社内の運用にあわせて作り替えてみてはいかがでしょうか? ちなみに、ソースの後ろに付け加えてマテリアル内の比重とユーザーパラメーターの重さをリンク付けすることも可能です。
------------------以下ソース-------------------- Sub CATMain()
On Error Resume Next
'--------------------------------------------- ' 変数宣言 '--------------------------------------------- Dim oDocument As Document ' Activeなドキュメント Dim oPart As Part ' アクティブなドキュメントのパート Dim oProduct 'As Product ' アクティブなドキュメントのプロダクト
Dim oManager As MaterialManager Dim iLinkMode As Integer
Dim oDocuments As Documents ' ドキュメントコレクション
Dim sFilepath As String ' マテリアルドキュメントのファイル名 Dim oMaterialDocument As MaterialDocument ' マテリアルドキュメント Dim oMaterialFamilies As MaterialFamilies ' マテリアルファミリーコレクション Dim oMaterialFamily As MaterialFamily ' マテリアルファミリー Dim oMaterials As Materials ' マテリアルコレクション Dim oMaterial As Material ' マテリアル
Dim nFamilyCount As Integer ' マテリアルのファミリー数 Dim nMaterialCount As Integer ' マテリアルの数
Dim docAnalyze As Analyze Dim docVolume As Double 'Porductのボリューム Dim parameters1 As Parameters 'パラメーター Dim d_Weight As Double Dim s_Weight As String Dim materialValue As Variant Dim aMaterial 'As AnalysisMaterial Dim productdensity As Double Dim value Dim partdocument As partdocument Dim partVolume As Double Dim partproduct As Product Dim partanalyze As Analyze
'--------------------------------------------- ' 今開いているドキュメントを取得 '--------------------------------------------- Set oDocument = CATIA.ActiveDocument
'--------------------------------------------- ' CATIAファイルが開かれているかどうか確認 '--------------------------------------------- If (oDocument Is Nothing) Then MsgBox ("CATPart/CATProductが開かれていることが前提です") Exit Sub End If
If (TypeName(oDocument) = "ProductDocument") Then 'プロダクトドキュメントの時 Set oProduct = oDocument.Product
'Productのボリュームを取得 Set docAnalyze = oProduct.Analyze docVolume = docAnalyze.Volume docVolume = docVolume / 1000000000
'Productのパラメーターを取得 Set parameters1 = oProduct.Parameters
'パラメーター追加 s_Weight = InputBox("重さを入力してください。※半角数字") d_Weight = CDbl(s_Weight) Call parameters1.CreateDimension("Weight", "MASS", d_Weight)
'比重の計算 productdensity = d_Weight / docVolume
ElseIf (TypeName(oDocument) = "PartDocument") Then 'パートドキュメントの時 Set oPart = oDocument.Part
'Productのボリュームを取得 Set partdocument = oPart.Parent Set partproduct = partdocument.Product Set partanalyze = partproduct.Analyze partVolume = partanalyze.Volume partVolume = partVolume / 1000000000 'Productのパラメーターを取得 Set parameters1 = oPart.Parameters 'パラメーター追加 s_Weight = InputBox("重さを入力してください。※半角数字") d_Weight = CDbl(s_Weight) Call parameters1.CreateDimension("Weight", "MASS", d_Weight) '比重の計算 productdensity = d_Weight / partVolume
End If
'--------------------------------------------- ' マテリアルライブラリーを開く '--------------------------------------------- sFilepath = "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" ←ここにマテリアルライブラリのあるパスを記入 Set oDocuments = CATIA.Documents Set oMaterialDocument = oDocuments.Open(sFilepath)
'--------------------------------------------- ' マテリアルライブラリー内のファミリーを取得 ' ・以下の方法でファミリーを取得 ' マテリアルライブラリ内で、 ' - 何番目かわかっていれば番号を指定して取得する ' - 名前がわかっていれば名前を指定して取得する '--------------------------------------------- Set oMaterialFamilies = oMaterialDocument.Families nFamilyCount = oMaterialFamilies.Count ' ファミリー数
' 何番目かわかっている時は数を指定する ' Set oMaterialFamily = oMaterialFamilies.Item(1)
' 名前がわかれば名前を指定しても取得できる Set oMaterialFamily = oMaterialFamilies.Item("Other")
'---------------------------------------------- ' 使用するマテリアルを取得 ' ・以下の方法でマテリアルを取得 ' ファミリー内で、 ' - 何番目かわかっていれば番号を指定して取得する ' - 名前がわかっていれば名前を指定して取得する '---------------------------------------------- Set oMaterials = oMaterialFamily.Materials nMaterialCount = oMaterials.Count ' ファミリー内のマテリアルの数
' 何番目かわかっている時は数を指定する 'Set oMaterial = oMaterials.Item(1)
' 名前がわかれば名前を指定しても取得できる Set oMaterial = oMaterials.Item("Material(For_Purch)")
Set aMaterial = oMaterial.AnalysisMaterial value = Str(productdensity) Call aMaterial.PutValue("SAMDensity", value)
'------------------------------------------------ ' マテリアルをドキュメントに設定する ' ・アクティブなドキュメントタイプにより取得するオブジェクトを変える ' - PartDocument : Part ' - ProductDocument: Product '------------------------------------------------ iLinkMode = 0 If (TypeName(oDocument) = "PartDocument") Then 'パートドキュメントの時 Set oPart = oDocument.Part Set oManager = oPart.GetItem("CATMatManagerVBExt") Call oManager.ApplyMaterialOnPart(oPart, oMaterial, iLinkMode)
Call oMaterialDocument.Close
ElseIf (TypeName(oDocument) = "ProductDocument") Then 'プロダクトドキュメントの時 Set oProduct = oDocument.Product Set oManager = oProduct.GetItem("CATMatManagerVBExt") Call oManager.ApplyMaterialOnProduct(oProduct, oMaterial, iLinkMode)
Call oMaterialDocument.Close
Else '上記以外はエラー Call MsgBox("本プログラムはCATPartかCATProductのみに有効です") End If
'-- マテリアルドキュメントを閉じる 'Call oMaterialDocument.Close
End Sub |
|
|