Equipment & Systems Engineering

Systems Diagrams

Creating an Electrical Schematic Document

How to create an electrical schematic document and place different schematic entities
Use Case

Abstract

This article discusses the CAAEDICreateSchema use case. This use case explains how to create a schematic document, how to create in-line references of schematic entities, how to place those references on a sheet, how to assemble and connect those entities, and how to save the document.


What You Will Learn With This Use Case

The following operations are detailed is this use case:

[Top]

The CAAEDICreateSchema Use Case

CAAEDICreateSchema is a use case of the CAAElecSchematicItf.edu framework that illustrates the ElecSchematicItf framework capabilities.

[Top]

What Does CAAEDICreateSchema Do

The goal of CAAEDICreateSchema is to create an electrical schematic document and a simple schema using in-line references.

Above is a CATIA image of the resulting electrical schema.

[Top]

How to Launch CAAEDICreateSchema

To launch CAAEDICreateSchema, you will need to set up the build time environment, then compile CAAEdiSchematicSample.cpp along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1].

To launch the use case, execute the following command:

mkrun -c "CAAEDICreateSchema output_name.CATProduct"

[Top]

Where to Find the CAAEDICreateSchema Code

CAAEDICreateSchema code is located in the CAAEDICreateSchema.m use case module of the CAAElecSchematicItf.edu framework:

Windows InstallRootDirectory/CAAElecSchematicItf.edu/CAAEDICreateSample.m
Unix InstallRootDirectory\CAAElecSchematicItf.edu\CAAEDICreateSample.m

where InstallRootDirectory is the root directory of your CAA V5 installation. It is made of a unique source file named CAAEdiSchematicSample.cpp.

[Top]

Step-by-Step

There are ten steps in CAAEDICreateSchema:

  1. Prolog
  2. Creating a drawing document
  3. Creating the equipment reference
  4. Creating the socket reference
  5. Creating the plug reference
  6. Placing the components in the main sheet
  7. Annotating the components
  8. Assembling the equipments and the sockets and connecting the plugs to the sockets
  9. Routing a cable between the plugs
  10. Epilog.

We will now comment each of those sections by looking at the code.

[Top]

Prolog

Creating a session. For more detail see[2].

[Top]

Creating a Schematic Document

...
      
  CATISchSession *piSchSession = NULL;
  RC = piSession->QueryInterface(IID_CATISchSession, (void **)&piSchSession);
...

  CATDocument *piSchemDoc = NULL;
  RC = piSchSession->CreateDocument("CATProduct", FALSE, &piSchemDoc);
...

To create a schematic document use the CreateDocument method of the CATISchSession interface. For more detail on this interface see [3]

[Top]

Creating the Equipment Reference

Here are the four steps to create a component reference:

  1. Create a Detail Sheet and a View on That Detail Sheet
  2. Create the Graphical Representation
  3. Create the Equipment
  4. Add the Connectors.

Create a Detail Sheet and a View on That Detail Sheet

To create the equipment reference, we need to create a detail sheet and a view on that detail sheet. For more detail on creating and managing detail sheets and views see [4].

Create the Graphical Representation

To create the graphical representation (a square made of four lines in this case), we use the CATI2DWFFactory interface. For more detail on this interface see [5].

Create the Equipment

...
  // get the application factory
  CATISchAppObjectFactory *piAppFact = NULL;
  RC = pSchSession->GetSchObjInterface(SCHELEClass_Application, IID_CATISchAppObjectFactory, (void **)&piAppFact);
  
  // create the applicative schematic component reference
  IUnknown *piCompoRef = NULL;
  RC= piAppFact->AppCreateCompRef(SCHELEClass_Equipment, &piCompoRef);
    
  // creating the list of GRR associated to my component
  CATSchListServices list;
  CATIUnknownList *piLUK = NULL;
  RC = list.CreateCATIUnknownList(&piLUK);
    
  IUnknown *piUK = NULL;
  RC = piNewView->QueryInterface(IID_IUnknown, (void **)&piUK);
    
  piLUK->Add(0,piUK);
  
  // getting schematic extension container
  IUnknown *piSchExtCont = NULL;
  RC = piSchSession->GetSchExtContainer (piSchemDoc, &piSchExtCont);

  CATISchBaseFactory *piBaseFact = NULL;
  RC = piSchExtCont->QueryInterface(IID_CATISchBaseFactory, (void **)&piBaseFact);
  
  // schematic ref. component creation
  CATISchComponent *piSchComp = NULL;
  RC = piBaseFact->CreateSchComponent(piCompoRef, piLUK, &piSchComp);
...

To create the equipment reference we must retrieve the application factory using the GetSchObjInterface method of the CATISchSession interface.

SCHELEClass_Application Type of objects the factory will be able to create (See the CATEdiSampleParameters.h header file)
IID_CATISchAppObjectFactory IID of the interface to which a pointer is requested
piAppFact The pointer retrieved to CATISchAppObjectFactory

The AppCreateComRef method of the CATISchAppObjectFactory interface is used to create the application component of type equipment.

SCHELEClass_Equipment Electrical schematic equipment type (See the CATEdiSampleParameters.h header file)
piCompoRef The pointer retrieved to IUnknown

The application component must then be associated with a graphical representation. To do this we use the CreateSchComponent method of the CATISchBaseFactory interface. We get the a pointer on the CATISchBaseFactory interface using the QueryInterface method on the schematic extension container which we got using the GetSchExtContainer method of the CATISchSession interface.

piCompoRef Pointer to a schematic component reference
piLUK List of pointers to views containing geometry
piSchComp The pointer retrieved to CATISchComponent

Add the Connectors

...
  // adding a WidePin and an AssemblyCtr
  CATISchCompConnector *piCompCntr = NULL;
  RC = piSchComp->QueryInterface(IID_CATISchCompConnector, (void **)&piCompCntr);
  
  double CntrLoc[2];
  CntrLoc[0] = 20.0;
  CntrLoc[1] = 20.0;
  CATISchAppConnector *piSchCntr = NULL;
  RC = piCompCntr->AddConnector(SCHELEClass_WidePinCtr, NULL, CntrLoc, &piSchCntr);

  CntrLoc[0] = 10.0;
  CntrLoc[1] = 10.0;
  CATISchAppConnector *piSchEqtAssemblyCntr = NULL;
  RC = piCompCntr->AddConnector(SCHELEClass_AssemblyCtr, NULL, CntrLoc, &piSchEqtAssemblyCntr);
...

The last step is to add the assembly connector and the wide pin connector. The assembly connector is used to assemble components together. In this case, we will assemble the socket and the equipment. The wide pin connector is used to connect to a cable extremity. We will create it but we will not use in this use case. The cable will be connected from plug to plug (plug1 to plug2). To add a connector to a component, we use the AddConnector method of the CATISchCompConnector interface.

SCHELEClass_WidePinCtr Electrical schematic wide pin type (See the CATEdiSampleParameters.h header file)
NULL Graphical representation of the component (if the pointer is NULL, then the connector will be added to all representation (case of a multi-representation component)
CntrLoc The position of the connector
piSchEqtAssemblyCntr The pointer retrieved to CATISchAppConnector

[Top]

Creating the Socket Reference

To create a socket reference, we go through the same steps as when creating the equipment reference. There are only two differences. The first one being the type of the component to create in the AppCreateCompRef method.

...
 RC= piAppFact->AppCreateCompRef(SCHELEClass_Socket, &piSocketRef);
...

The second difference is the types of the connectors to add on the socket. We add an assembly connector to assemble the socket to the equipment and a mating connector to connect the socket to the plug. We also add a wide pin connector which we will not use.

...
  RC = piCompSocketCntr->AddConnector(SCHELEClass_WidePinCtr, NULL, CntrLoc, &piSchWidePinCntr);
...
  RC = piCompSocketCntr->AddConnector(SCHELEClass_MatingCtr, NULL, CntrLoc, &piSchMatingSCntr);
...
  RC = piCompSocketCntr->AddConnector(SCHELEClass_AssemblyCtr, NULL, CntrLoc, &piSchAssemblyCntr);
...

[Top]

Creating the Plug Reference

To create a plug reference, we go through the same steps as when creating the equipment reference. There are only two differences. The first one being the type of the component to create in the AppCreateCompRef method.

...
  RC= piAppFact->AppCreateCompRef(SCHELEClass_Plug, &piPlugRef);
...

The second difference is the types of the connectors to add on the plug. We add a mating connector to connect the plug to the socket and we add a wide pin connector to connect the cable.

...
  RC = piCompPlugCntr->AddConnector(SCHELEClass_WidePinCtr, NULL, CntrLoc, &piSchWidePinPgCntr);
...
  RC = piCompPlugCntr->AddConnector(SCHELEClass_MatingCtr, NULL, CntrLoc, &piSchMatingPgCntr);
...

[Top]

Placing the Components on the Main Sheet

Before placing the components on the main sheet, we must make it active. For more detail on managing sheets see [4].

...
  CATISchComponent *piComponentInst1 = NULL;
  double iDb6Axis1[6] = { 1.0, 0.0, 0.0, 1.0,  50.0,  50.0};
  RC = piSchComp->PlaceInSpace(NULL, iDb6Axis1, &piComponentInst1);
...

To place a component on the main sheet, we use the PlaceInSpace method of the CATISchComponent interface. The first argument is a pointer to the graphical representation of the component. If the pointer is NULL, then the primary representation is used. The second argument is the position on the sheet. The result is a pointer on the instance of the component.

NULL Graphical representation of the component (if the pointer is NULL, then the connector will be added to all representation (case of a multi-representation component)
iDb6Axis1 The position of the connector
piComponentInst1 The pointer retrieved to CATISchComponent

[Top]

Annotating the Components

To annotate the components, we have to get a pointer on the annotation factory. For more detail on annotations see [6].

[Top]

Assembling the Equipments and the Sockets and Connect the Plugs to the Sockets

...
  // Eqt1
  CATISchAppConnectable *piEqtConnectable1 = NULL;
  RC = piComponentInst1->QueryInterface(IID_CATISchAppConnectable, (void **)&piEqtConnectable1);
 
  CATICStringList *piLAssyCtrType = NULL;
  RC = list.CreateCATICStringList(&piLAssyCtrType);

  piLAssyCtrType->Add(0, SCHELEClass_AssemblyCtr);

  CATIUnknownList *piLEqtAsyConnector1 = NULL;
  RC = piEqtConnectable1->AppListConnectors(piLAssyCtrType, &piLEqtAsyConnector1);

  IUnknown *piEqtCntr1 = NULL;
  RC = piLEqtAsyConnector1->Item(0, &piEqtCntr1);
  
  CATISchAppConnector *piAppEqtCntr1 = NULL;
  RC= piEqtCntr1->QueryInterface(IID_CATISchAppConnector, (void **)&piAppEqtCntr1);
...

The first step to assemble the equipment and the socket is to get a pointer on both the assembly connector of the equipment and the assembly connector of the socket. To do that, we use the AppListConnectors method of the CATISchAppConnectable interface.

...
  CATISchAppConnection *piAssyConnection1 = NULL;
  RC = piAppEqtCntr1->AppConnect(piAppSocketCntr1, &piAssyConnection1);
...

To connect both connectors together, we use the AppConnect method of the CATISchAppConnector interface.

To connect the plug and the socket, we go through the same steps but with a mating connector instead of the assembly connector.

[Top]

Routing a Cable Between the Two Plugs

...
  IUnknown *piUKAppRoute = NULL;
  RC = piAppFact->AppCreateRoute(SCHELEClass_Cable, &piUKAppRoute);
...

The first step is to create a route object using the AppCreateRoute of the CATISchBaseFactory interface. The first argument is type of route (electrical cable in our case) we want to create. The result is a pointer on a route object.

SCHELEClass_Cable Electrical schematic cable type (See the CATEdiSampleParameters.h header file)
piUKAppRoute The pointer retrieved to IUnknown
...

  double pPts[14] = {80.0, 60.0, 73.0, 60.0, 73.0, 147.0, 197.0, 147.0, 197.0, 173.0, 170.0, 173.0, 170.0, 160.0};

  // create the cable in the main sheet
  CATISchRoute *piSchRoute = NULL;
  RC = piBaseFact->CreateSchRouteByPoints(piUKAppRoute, pPts, 14, &piSchRoute);
...

Then we need to link the route object with a graphical representation. The CreateSchRouteByPoints method of the CATISchBaseFactory interface does that.

piUKAppRoute Pointer to the route.
pPts Points by which the cable will go through (the position of the plug's wide pins should be the first and the last points)
14 Size of the array
piSchRoute The pointer retrieved to CATISchRoute
...
RC = piRouteCntr1->AppConnect(piAppPlugWPCntr1, &piConnection1);
...

The last step is to connect both extremities of the cable to the plugs' wide pins. We have to retrieve pointers on the wide pins and on the cable extremities, the same way we did for the assembly connectors or the mating connectors. Then, using the AppConnect method of the CATISchAppConnector interface we create the connection between the wide pin of the first plug and the first extremity of the cable and the connection between the wide pin of second plug and the second extremity of the cable.

[Top]

Epilog

...
  RC = CATDocumentServices::SaveAs ( *piSchemDoc, argv[1]);
...

To save the document, we use CATDocumentServices::SaveAs method. For more detail on managing documents see [2].

...
CATSession::Delete_Session (pSessionIdent);
...

The session is deleted before exit.

[Top]


In Short

This use case has shown you how to create a schematic document, how to create in-line references of schematic entities, how to place those references on a sheet, how to assemble, and connect those entities and how to save the document.

Following operations have been detailed is this use case:

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Creating a New Document
[3] Creating Schematic Application Components
[4] Creating Sheets and Views in a CATDrawing Document
[5] Creating Frames and Title Blocks in a CATDrawing Document
[6] Editing Dimension Dress-Up
[Top]

History

Version: 1 [Nov 2001] Document created
[Top]

Copyright © 2001, Dassault Systèmes. All rights reserved.