The following table contains information on the ISCModelObjectCollection interface, which is used when you create a new model object:
Signature |
Description |
Valid Arguments |
---|---|---|
ISCModelObjectCollection * Collect(VARIANT Root, VARIANT ClassId [optional], VARIANT Depth [optional], VARIANT MustBeOn [optional], VARIANT MustBeOff[optional]) |
Creates a Model Objects collection, which represents a subcollection of itself |
Root:
ClassId:
Depth:
MustBeOn:
MustBeOff:
|
ISCModelObject * Add(VARIANT Class, VARIANT ObjectId [optional]) |
Adds an object of type Class to the model |
Class:
ObjectId:
|
Example 20
The following example illustrates how to create objects using C++. The example uses a Session object from Example 6:
// NOTE: ISCSession::BeginTransaction() must be called prior to calling this // function // ISCSession::CommitTransaction() must be called upon returning from this // function void CreateObject(ISCSessionPtr & scSessionPtr, CString & csType, ISCModelObjectPtr & parentObj) { variant_t transactionId; // transaction ID for the session VariantInit(&transactionId); transactionId = scSessionPtr->BeginTransaction(); ISCModelObjectCollectionPtr childObjColPtr = scSessionPtr->GetModelObject()->Collect(parentObj->GetObjectId(),vtMissing,(long)1); // get // child objects // Add child object to collection ISCModelObjectPtr childObjPtr = childObjColPtr->Add(COleVariant(csType)); // … scSessionPtr->CommitTransaction(transactionId); }
The following example illustrates how to create objects using Visual Basic .NET. The example uses a Session object from Example 6:
Public Sub AddNewObject(ByRef scSession As SCAPI.Session, _ ByRef parentObj As SCAPI.ModelObject, type As String) Dim scObj as SCAPI.ModelObject Dim scChildObjCol As SCAPI.ModelObjects Dim transactionID as Variant transactionID = scSession.BeginTransaction scChildObjCol = scSession.ModelObjects.Collect(parentObj, , 1) ' child objects collection scObj = scChildObjCol.Add(type) ' add new object to the child object collection scSession.CommitTransaction( transactionID ) End Sub
Copyright © 2016 CA Technologies.
All rights reserved.
|
|