- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I've got a interesting question for you, that I havent been able to resolve myself, as follows:
Background: I have a suite of 50 Plant 3D models that have been created. However, none of the models have spool numbers assigned to them.
Question: Is it possible to edit the properties of pipe or any object in Plant 3D using VBA or VB.NET? (To avoid manually opening up each model and assigning spool numbers to each segment of pipe in the model).
Currrently I am able to do the following with Plant 3D myself:
1. Open Plant 3D
2. Open specified drawing
3. Select all objects in Plant 3D model
4. Output object names to the immediate window in VBA
5. Control certain aspects of the objects with the PLANT3D COM LIBRARY - This is where I am running into issues, the COM library doesn't appear to have a build in "spool property" to edit.
Please find sample code below for your reference.
Sub Plant_3D_Edit_Attributes()
Dim plant_app As AutoCAD.AcadApplication
Dim doc As AcadDocument
Dim appname As String
Dim sht_data As Worksheet
Dim objSS As AcadSelectionSet
Dim ent As AcadEntity
Dim pline As AcadLWPolyline
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Dim Groupcode As Variant
Dim DataValue As Variant
Dim i As Integer
Dim pipe As PnP3dCOMLib.AcPnP3dPipeInlineAsset
'Creating AutoCAD Plant 3D instance
appname = "'acad.exe'"
Call Create_Model.App_Open(appname)
'This section of code is sometimes weird and wont create the plant 3D instance until it is opened once in windows.
If Create_Model.App_Open(appname) = "True" Then
'AutoCAD open so do nothing
Set plant_app = GetObject(, "AutoCAD.Application.19")
Else
Set plant_app = CreateObject("AutoCad.Application.19") 'ACAD Plant 3D needs to be set as the default ACAD application
plant_app.Visible = True
End If
Set doc = plant_app.Documents.Open("C:\Josh\Model Generation Environment\Plant 3D Projects\PLPR Test Project\Plant 3D Models\Plant 3D Model - K48.dwg")
'Create selection set for finding all paperspace blocks
On Error Resume Next
doc.SelectionSets.Item("ss").Delete
On Error GoTo 0
'Create selection set
Set objSS = doc.SelectionSets.Add("ss")
'Defining filter variables
FilterType(0) = 67 'Select all
FilterData(0) = 0 '0 = Model Space 1 = Paper Space
Groupcode = FilterType
DataValue = FilterData
'Select all objects in paper space
objSS.Select acSelectionSetAll, , , Groupcode, DataValue
For i = 1 To objSS.count - 1
Debug.Print objSS.Item(i).ObjectName 'Prints name component type, i.e. flange, gasket etc.
If objSS.Item(i).ObjectName = "AcPpDb3dPipeInlineAsset" Then
Set pipe = objSS.Item(i)
End If
Next i
End Sub
Thanks alot in advance for the assistance.
Cheers,
Josh
Solved! Go to Solution.