Option Explicit
'---------------------------------------------------------------------------
'COPYRIGHT DASSAULT SYSTEMES 2011

' ****************************************************************************
'
' Purpose:       To create an SDD Design unit and features in it.
'
' Assumptions:   No document need to be active
'
' Author:
' Languages:     VBScript
' Version:       V5R21
' Locales:       English
' CATIA Level:   V5R21
'
' ****************************************************************************
Sub CATMain()

  'Create a Product Document
  Dim NewProdDoc As ProductDocument
  Set NewProdDoc = CATIA.Documents.Add("Product")

  'Get the Product from Product Document
  Dim RootPrd As Product
  Set RootPrd = NewProdDoc.Product

  'Select the Product Document and Add Product to this selection
  Dim SelectionObj As Selection
  Set SelectionObj = NewProdDoc.Selection
  SelectionObj.Add RootPrd

  'Create a SDD product by Finding it it selection
  Dim SddProductObj As SddProduct
  Set SddProductObj = SelectionObj.FindObject("CATIASddProduct")

  Dim sddpart As Part
  Set sddpart = SddProductObj.CreateDesignUnit

  Dim FactoryObj As SfmFactory
  Set FactoryObj = sddpart.GetCustomerFactory("SfmFactory")


  'Retrieve the Manager from the Factory
  Dim ManagerObj As SfmManager
  Set ManagerObj = FactoryObj.GetManager
  
  'Add Hull Using Manager
  ManagerObj.AddHull

  'Define Shell Plate Support
  Dim ShellSupport As AnyObject
  Set ShellSupport = sddpart.FindObjectByName("Hull1234")
  Dim ShellSupportRef As Reference
  Set ShellSupportRef = sddpart.CreateReferenceFromObject(ShellSupport)
  
  Dim ShellSuperplate1 As SfmSuperPlate
  Set ShellSuperplate1 = FactoryObj.AddSuperPlate("ShellPanel", ShellSupportRef, Nothing)
  'Define Limit
  Dim ShellPlateLimit As AnyObject
  Set ShellPlateLimit = sddpart.FindObjectByName("LONG.0")
  Dim ShellPlateLimitRef As Reference
  Set ShellPlateLimitRef = sddpart.CreateReferenceFromObject(ShellPlateLimit)
  
  'Define Orientation of Third Limit
  Dim ShellPlateOrnt As Long
  ShellPlateOrnt = 5
  ShellSuperplate1.AddLimit ShellPlateLimitRef, ShellPlateOrnt

  ShellSuperplate1.Thickness = "3.0"
  
  ShellSuperplate1.Run
  sddpart.Update
End Sub