pycatia.mec_mod_interfaces.instance_factory¶
Module initially auto generated using V5Automation files from CATIA V5 R28 on 2020-06-11 12:40:47.360445
Warning
The notes denoted “CAA V5 Visual Basic Help” are to be used as reference only. They are there as a guide as to how the visual basic / catscript functions work and thus help debugging in pycatia.
- class pycatia.mec_mod_interfaces.instance_factory.InstanceFactory(com_object)¶
Note
CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
System.IUnknownSystem.IDispatchSystem.CATBaseUnknownSystem.CATBaseDispatchSystem.AnyObjectMecModInterfaces.FactoryInstanceFactoryRepresents the CATIAInstanceFactory.Role: This interface is used to create a new instance of a shape reference(ShapeInstance ) or a hybrid shape reference ( HybridShapeInstance ) in case ofthe instantiation of a User Feature.It is also used to instantiate a Power Copy reference.This interface contains two protocols of instantiation:The first protocol is dedicated to User Feature instantiationonly.It is defined by a single method: AddInstance . It creates a shape orhybrid shape instance depending on the result of the UserFeature.Use this method when you want to perform only one instantiation of thereference. Read the document containing the User Feature reference andinstantiate it.As the document containing the reference is released from the session atthe end of the instantiation, it is not recommmended to use this method if youwant to perform several instantiations of the same reference in aloop.In that case, prefer the second protocol of instantiation.The second protocol is dedicated to both User Feature and Power Copyinstantiations.It is defined by several methods that must be called inorder.For User Feature instantiation, these methods are an alternative way ofthe AddInstance method.It is recommended to use the second protocol to perform severalinstantiations of the same reference in a loop.For Power Copy instantiation, it is the only way of instantiating areference.The instantiation process is composed of three majorsteps:The first step BeginInstanceFactory consists in initializing theInstanceFactory with the reference and the document where it isstored.This step must be called once at the beginning whatever the number ofinstantiations are done.Optional step InstantiationMode allow the user to specify the mode ofthe instantiation, that is to say “After” or “Inside”.If this method is not called, the instantiation mode will be chosenaccording to the BeginInstantiate method.The second step is the instantiation itself: it is composed of fivemethods that must be called in the order.This set of five methods can be called in a loop in order to makeseveral instantiations.The method BeginInstantiate is used to initialize all data of thereference.The method PutInputData is used to set a value to any input of thereference.The method GetParameter is used to retrieve any parameter of thereference in order to modify its value.The method Instantiate is used to duplicate the reference. Itreturns the created instance when it does exist.The method EndInstantiate is used to indicate that theinstantiation is done.The third step EndInstanceFactory consists in ending the instantiationand cleaning the InstanceFactory.When doing several instantiations in a loop, this step must be calledjust once at the end of all instantiations.- add_instance(i_reference: AnyObject) AnyObject ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func AddInstance(AnyObject iReference) As AnyObjectCreates a new instance of a shape or hybrid shape.Parameters:iReferenceThe reference shape or hybrid shape.Example:This example creates the instance NewInstance in thepart.Set NewInstance = instanceFactory.AddInstance(reference)
- begin_instance_factory(i_name_of_reference: str, i_name_of_document: str) None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub BeginInstanceFactory(CATBSTR iNameOfReference,CATBSTR iNameOfDocument)Initializes the instantiation process with the document containing thereference.Role: Use this method to start instantiating a reference in the currentdocument.In that method, the document containing the reference is locked insession.It will be unlocked in the last step EndInstanceFactory .Parameters:iNameOfReferenceThe name of the reference to be instantiated.iDocumentFileNameThe name of the file containing the document where to find thereference to be instantiated.Example:The following example initializes the factory with a document and areference:InstanceFactory.BeginInstanceFactory”NameOfReference”,”c:tmpNameOfDocument.CATPart”
- Parameters:
i_name_of_reference (str) –
i_name_of_document (str) –
- Return type:
None
- begin_instantiate() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub BeginInstantiate()Initializes the data of the reference.Role: This is the first method of the second step ofinstantiation.It is used to initialize all data of the reference in thefactory.Example:The following example shows how to initialize thefactory:InstanceFactory.BeginInstantiate
- Return type:
None
- end_instance_factory() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub EndInstanceFactory()Ends the instantiation process.Role: Use this method to end the instantiation process.In that method the document containing the reference is unlocked andreleased from the session.Example:The following example shows how to end theinstantiation:InstanceFactory.EndInstanceFactory
- Return type:
None
- end_instantiate() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub EndInstantiate()Ends the instantiation of the reference.Role: This is the fifth and last method of the second step ofinstantiation.It is used to end the instantiation: after this step, all the links to thereference are broken.Example:The following example shows how to end theinstantiation:InstanceFactory.EndInstantiate
- Return type:
None
- get_parameter(i_name: str) AnyObject ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func GetParameter(CATBSTR iName) As AnyObjectRetrieves a parameter of the reference by its name.Role: This is the third method of the second step ofinstantiation.This step is optional.It is used to retrieve a parameter of the reference in order to change itsvalue, using the ValuateFromString method of the Parameterinterface.It has to be called on each parameter whose value has to bechanged.Parameters:iNameThe name of the parameter.Example:The following example retrieves a parameter on thereference:Set parameter = InstanceFactory.GetParameter(“Parameter1”)
- Parameters:
i_name (str) –
- Return type:
- instantiate() AnyObject ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func Instantiate() As AnyObjectInstantiates the reference in the current document.Role: This is the fourth method of the second step ofinstantiation.It is used to duplicate or instantiate the data of thereference.In case of Power Copy instantiation, the data are duplicated and thereis no created instance.In case of User Feature instantiation, the data are instantiated and aninstance is created and returned.Example:The following example instantiates the reference:Set Instance = InstanceFactory.Instantiate
- Return type:
- property instantiation_mode: str¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384)
- o Property InstantiationMode(CATBSTR iInstantiationModeBSTR) (WriteOnly)Sets the mode of instantiation to “Inside” or “After”.Role: This method should be called BEFORE the method BeginInstantiate totake into account the desired instantiation mode.It is used to set the destination path of insertion of the templatereference.Example:The following example shows how to determine the instantiation mode(Mode’s value is “Inside” or “After”):InstanceFactory.InstantationMode = Mode
- Return type:
str
- put_input_data(i_name: str, i_input: AnyObject) None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub PutInputData(CATBSTR iName,CATBaseDispatch iInput)Sets a value to an input of the reference.Role: This is the second method of the second step ofinstantiation.It is used to set a value to any input of the reference.It has to be called on each input of the reference.Parameters:iNameThe name of the input.iInputThe element to set as the new value of the input.All types ofBoundary object are possibly supported.Example:The following example sets a value to an input of the reference: The inputis a point and its name is Input1.InstanceFactory.PutInputData “Input1”,point1
- Parameters:
i_name (str) –
i_input (AnyObject) –
- Return type:
None