' This sample shows how to instantiate a User Feature named "UDFBoundingSphere"
' which is stored in a 3D Shape Representation Reference named
' "Bounding_Box_Reference_000" and with a majorrevision = "---".
' There is 1 input: "Surface". To run this sample, open in session the
' 3D Shape Representation where you want to instantiate the User Feature. It must contain at least a
' Surface.1 surface.
' Go to Tools \ Macro \ Macros ... and run this script.
Sub CATMain()
'---------------------------------------------------------------------------
CATIA.SystemService.Print "Retrieve the Representation Reference where the instantiation is performed"
Set PartDocumentDest = CATIA.ActiveEditor.ActiveObject
CATIA.SystemService.Print "PartDocumentDest.TypeName = " & TypeName(PartDocumentDest)
If TypeName(PartDocumentDest)<> "Part" Then
MsgBox "Error: TypeName activeObject is not a part"
End If
'---------------------------------------------------------------------------
CATIA.SystemService.Print "Retrieve the Instance factory on this part container"
Set factory = PartDocumentDest.GetCustomerFactory("InstanceFactory")
'---------------------------------------------------------------------------
CATIA.SystemService.Print "Initialize the process with the name of the Power Copy, the name of the 3D Shape Representation Reference, and the majorrevision"
factory.BeginInstanceFactory "UDFBoundingSphere", "Bounding_Box_Reference_000", "---"
'----------------------------------------------------------------------------
CATIA.SystemService.Print "Begin the instantiation"
factory.BeginInstantiate
'----------------------------------------------------------------------------
CATIA.SystemService.Print "Valuate the input named Surface"
Set input1 = PartDocumentDest.FindObjectByName("Surface.2")
factory.PutInputData "Surface", input1
'---------------------------------------------------------------------------
CATIA.SystemService.Print "Instantiate the Power Copy"
Set Instance = factory.Instantiate
'----------------------------------------------------------------------------
CATIA.SystemService.Print "End the instantiation process"
factory.EndInstantiate
'-----------------------------------------------------------------------------
CATIA.SystemService.Print "Release the 3D Shape Representation containing the Rep Template reference"
factory.EndInstanceFactory
'-----------------------------------------------------------------------------
CATIA.SystemService.Print "Launch a global Update"
PartDocumentDest.Update
'----------------------------------------------------------------------------
End Sub