Create new Object in the database
In the 3DEXPERIENCE Platform, documents are replaced by objects or PLM entity
. Everything is now stored in the database. Parts, Drawings, Products, Publications...
In Catia V5, creating a new part was quite simple. You could use a method like this to create a part (error handling and other checks omitted):
Function CreateNewPartDocument() As PartDocument
Dim Docs As Documents
Set Docs = CATIA.Documents
Dim PartDoc As PartDocument
Set PartDoc = Docs.Add("Part")
Set CreateNewPartDocument = PartDoc
End Sub
In the new world, to create a new object, you need to use the application's session services (and not the editor's).
Remember that after creating the new object, it will be loaded in a new editor. This means that the CATIA.ActiveEditor
is now the newly created object.
Option Explicit
Sub CatMain()
Dim NewEditor As Editor
Set NewEditor = CreateNewDbObject("3DShape")
End Sub
Public Function CreateNewDbObject(ByVal ObjectType As String) As Editor
If Len(Trim(ObjectType)) = 0 Then Exit Function
On Error GoTo ErrorHandler
Dim NewService As PLMNewService
Set NewService = CATIA.GetSessionService("PLMNewService")
Call NewService.PLMCreate(ObjectType, CreateNewDbObject)
Exit Function
ErrorHandler:
Call MsgBox("Object of type '" & ObjectType & "' could not be created.", vbCritical, "Error while creating new database object.")
End Function
The ObjectType parameter can be of several types. For example:
- 3DShape
- 3DPartt
- VPMReference to create a Physical Product
- Drawing
- ...
However, only the 3DShape
and Drawing
options are valid with the basic licences. If you use any other type, you will receive error “Operation not authorized”, as a specific licence is required (E70). If you want to create these objects in the database, take a look at WebServices and EKL.