私は複雑な煙突の3Dモデルを持っています。これは本質的に装飾的な特徴を持つ円筒形のチューブです。私はその長さに沿っていくつかのポイントでセクションのプロパティを見つけるVBAスクリプトを書いてみたいですが、私はそれをやる方法が本当にわかりません。オンライン検索からAutoCAD VBA:オブジェクトの選択
、私はその後、上MASSPROPを実行することができますが、私はそれを終えることがどのように非常にわからない時点でセクションに置くコードを書くことができた...私は」だと思いますたった1行分のコードです。私はちょうど私が作成したセクションを選択する必要があります。
私の助けが必要なコードは、私のほぼ完全なコードです。
Public Sub Section()
Dim SolidObject As Acad3DSolid
Dim NewRegionObject As AcadRegion
Dim PlaneOrigin As Variant
Dim PlaneXaxisPoint As Variant
Dim PlaneYaxisPoint As Variant
Dim PickedPoint As Variant
On Error Resume Next
With ThisDrawing.Utility
.GetEntity SolidObject, PickedPoint, vbCr & "Select solid to cut."
If Err Then
MsgBox "Selected solid must be a 3DSolid"
Exit Sub
End If
PlaneOrigin = .GetPoint(PickedPoint, vbCr & "Select point to define origin.")
PlaneXaxisPoint = .GetPoint(PickedPoint, vbCr & "Select point to define x-axis.")
PlaneYaxisPoint = .GetPoint(PickedPoint, vbCr & "Select point to define y-axis.")
Set NewRegionObject = SolidObject.SectionSolid(PlaneOrigin, PlaneXaxisPoint, PlaneYaxisPoint)
End With
ThisDrawing.SendCommand ("qaflags" & vbCr & "2" & vbCr) 'This is needed for the operation
ThisDrawing.SendCommand ("massprop" & vbCr)
'How do I select my NewRegionObject???
ThisDrawing.SendCommand (vbCr & vbCr & "y" & vbCr & vbCr & "y" & vbCr)
End Sub
私は、新しく作成されたセクションでMASSPROPを実行するには、このコードを取得できた場合は罰金、私は煙突に沿ったいくつかの点でプロセスを自動的に行うには、それを適応させることができるはずですので、私は1行だけだと思いますコードオフ。あなたの助けのための
おかげで、 トム
あなたが本当にあなたのコードをインデントする必要があります。 'Sub ... End Sub'はブロックです。 「With ... End With」だけではなく、「With With ... With With」は別のものです! –
[API](http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-DFE47717-F7AF-443B-AD78-4E0BB60121C7)が役に立ちますが、 .sendCommandから返されたオブジェクトは、あなたが持っている何らかの手段でregionオブジェクトを実行するか、または 'find'する関数を使って書き直してください。 –