AutoCAD Command Line API Specification
In this version of CI, an AutoCAD user is able to input AutoLISP commands that execute various CI functions. The API specifications are described below (also available as a document. See attachments).
CIA – Command Line API Specification
Limitations of AutoLISP
AutoLISP does not naturally support a “long” datatype, yet Maximo® Real Estate and Facilities uses long values for many items, such as record ID. In particular, numbers > 2147483647 will automatically be converted to a double in lisp (using exponential notation), so CAD Integrator will not receive the correct value from Acad. To work around this, always quote your record ID values, e.g.: "2147483648". AutoLISP commands only work from the context of a single document. Therefore we cannot have an open drawing or close drawing command run from within a lisp function, and then execute the remainder of the function in the newly opened drawing. The open/close drawing must be run outside the lisp function, then the drawing must be activated, and then call the lisp function(s) to do operations on the open drawing.
Command Specifications (12.1.5.x and later)
- CiApplyTheme
- Applies the specified theme by name to the attached drawing. If no theme name is provided, or
the theme name provided is blank, it will instead apply whatever the server default theme is. Note
that the themeName must be the name, not label, and can be found by running (CiQueryThemes).
Table 1. (CiApplyTheme [themeName]) Arguments themeName A string that specifies the theme name. Case sensitive. Optional. Return Values Returns T if applying the theme was successful, nil otherwise. Examples Apply the “Space Details” theme.
Command: (CiApplyTheme "triSpaceDetails001")
T
Apply the default theme.
Command: (CiApplyTheme "") or (CiApplyTheme)
T
- CiQueryThemes
- Returns the available themes for the server for this user.
Table 2. (CiQueryThemes) Return Values If there is at least one theme, it will return a list of “themes”, where each theme is itself a list of (name, label). The name is used in the (CiApplyTheme) command. The label is what you would see in the Apply Themes dialog. If there are no themes, returns T. If the command fails for any reason, returns nil. Example Command: (CiQueryThemes)
(("triAssetSearch001" "Search Equipment") ("triAssets001" "Assets") ("triBuildingSearch001" "Search Building") ("triChargeToOrg001" "Charge To Organization") ("triDefault" "Default") ("triDefault - CAD" "CAD Default") ("triEmergencyExitPlan001" "Emergency Exit Plan") ("triKeyRooms001" "Key Rooms") ("triOccupancyOrg001" "Occupancy Organization") ("triPeople001" "People") ("triPeopleSearch001" "Search People") ("triReserve001" "Reservable Spaces") ("triRoomSearch001" "Search Room") ("triSpaceDetails001" "Space Details"))
- CiApplyReport
-
Applies the specified graphic report by name to the attached drawing. If no report name is provided, or the report name provided is blank, it will clear the report instead.Note: The reportName must be the name, not label, and can be found by running (CiQueryReports).
Table 3. (CiApplyReport [report Name]) Arguments reportName A string that specifies the graphic report name. Case sensitive. Optional. Return Values Returns T if applying the report was successful, nil otherwise. Examples Apply the Occupancy Status Graphic report.
Command: (CiApplyReport "triSpace - Graphic - Occupancy Status")
T
Clear the graphic report.
Command: (CiApplyTheme "") or (CiApplyTheme)
T
- CiQueryReports
- Returns the available graphics reports for the server for this user.
Table 4. (CiQueryReports) Return Values If there is at least one graphic report, it will return a list of reports, where each report is itself a list of (name, title). The name is used in the (CiApplyReport) command. The title is what you would see in the Apply Report dialog. If there are no graphic reports, returns T. If the command fails for any reason, returns nil.
Example Command: (CiQueryReports)
(("triSpace - Graphic - Asset Locations" "Asset Locations") ("triSpace - Graphic - Asset Type" "Asset Type") ("triSpace - Graphic - Chargeback Status" "ChargebackStatus") ("triSpace - Graphic - Charged To Organization" "Charged To Organization") ("triSpace - Graphic - Leases" "Lease Summary") ("triSpace - Graphic - Occupancy Organization" "Occupancy Organization") ("triSpace - Graphic - Occupancy Status" "Occupancy Status") ("triSpace - Graphic - Reservable" "Reservable") ("triSpace -Graphic - Reservable By Space Class" "Reservable By Space Class") ("triSpace - Graphic - Space Class" "Space Class")
- CiApplyLabelStyle
-
Applies the specified label style by name to the attached drawing. If no label style name is provided, or it is blank, it will clear the labels on the drawing.Note: The labelStyleName must be the name, not label, and can be found by running (CiQueryLabelStyles).
Table 5. (CiApplyLabelStyle [labelStyleName]) Arguments labelStyleName A string that specifies the label style name. Case sensitive. Optional. Return Values Returns T if applying the label style was successful, nil otherwise. Examples Apply the “Space (Area)” Label Style.
Command: (CiApplyLabelStyle "triSpace001")
T
Clear the labels.
Command: (CiApplyLabelStyle "") or (CiApplyLabelStyle)
T
- CiQueryLabelStyles
- Returns the available label styles for the server for this user.
Table 6. (CiQueryLabelStyles) Return Values If there is at least one label style, it will return a list of label styles, where each label style is itself a list of (name, label). The name is used in the (CiApplyLabelStyle) command. The label is what you would see in the Apply Labels dialog. If there are no label styles, returns T. If the command fails for any reason, returns nil.
Examples Command: (CiQueryLabelStyles)
(("triAsset001" "Asset") ("triChargeToOrg001" "Charge To Organization") ("triOccupancyOrg001" "Occupancy Organization") ("triPeople001" "People") ("triReserve002" "Reservable (Name Only)") ("triReserve001" "Reservable (Room Details)") ("triSpace001" "Space (Area)") ("triSpace002" "Space (Name)") ("triSpaceClass001" "SpaceClass"))
- CiApplyLabelFilter
-
Applies the specified label filter by name to the attached drawing. If no label filter name is provided, or it is blank, it will clear the labels on the drawing.Note: The labelFilterName must be the name, not label, and can be found by running (CiQueryLabelFilters).
Table 7. (CiApplyLabelFilter [labelFilterName]) Arguments labelFilterName A string that specifies the label filter name. Case sensitive. Optional. Return Values Returns T if applying the label filter was successful, nil otherwise. Examples Apply the Office/Workstation Label Filter.
Command: (CiApplyLabelFilter "triOfficeWorkstation001")
T
Clear the labels.
Command: (CiApplyLabelFilter "") or (CiApplyLabelFilter)
T
- CiQueryLabelFilters
- Returns the available label filters for the server for this user
Table 8. (CiQueryLabelFilters) Return Values If there is at least one label filter, it will return a list of label filters, where each label filter is itself a list of (name, label). The name is used in the (CiApplyLabelFilter) command. The label is what you would see in the Apply Labels dialog. If there are no label filters, returns T. If the command fails for any reason, returns nil. Example Command: (CiQueryLabelFilters)
(("triOfficeWorkstation001" "Office/Workstation"))
Command Specifications (12.1.2.x and later)
- CiDetachAll
-
Detaches the drawing and all attached entity data from the server. This is equivalent to the TRGA_Detach command and selecting Yes to the prompt for removing attachment data from all attached entities
(CiDetachAll)
Return Values: Returns T if the detach operation was successful, nil otherwise.
- CiDetachDrawing
-
Detaches the drawing from the server. This is equivalent to the TRGA_Detach command and selecting “No” to the prompt for removing attachment data from all attached entities.
(CiDetachDrawing)
Return values: Returns T if the detach operation was successful, nil otherwise.
- CiSyncFull
- Fully syncs the current drawing with the server.
(CiSyncFull)
Return values: Returns T if successful, nil otherwise.
Command Specifications (12.x and later)
- CiAttachDrawing
- Attaches the current drawing to the server.
Table 9. (CiAttachDrawing appDefName drawingUnitName recordID) Arguments appDefName A string that specifies the name of the application definition to attach the drawing with.
drawingUnitName A string that specifies the drawing unit to attach the drawing with.
recordID The record ID of the server object to attach to. Should be enclosed in quotes.
Return Values If attach was successful, returns T. If the operation failed for any reason, returns nil. Example Attaches the current drawing using the Facilities Management application definition, inches, and to the record on the server with id 12246754:
Command: (CiAttachDrawing "Facilities Management-Primary" "inches" "12246754")
T
- CiAttachGross
- Attaches the gross area of the current drawing to the largest boundary with the layer name
specified.
Table 10. (CiAttachGross layername [layername]...) Arguments layername A string that specifies the layer name to attach with. If more than one layer name is provided, the command will use the first layer in the arguments that exists in the drawing. Return Values If attach gross was successful, returns T. If the operation failed for any reason, returns nil. Example Attach the current drawing's gross area to the largest boundary on the GrAE-24 layer:
Command: (CiAttachGross "GrAE-24")
T
Attach the current drawing's gross area to layer1 if it is on the drawing, layer2 if it is on the drawing, or layer3 if it is on the drawing, in that order. If no layers are present, the command fails and return nil.
Command: (CiAttachMGross "layer1" "layer2" "layer3")
T
- CiAttachMGross
- Attaches the measured gross area of the current drawing to the largest boundary with the layer
name specified.
Table 11. (CiAttachMGross layername [layername]... ) Arguments layername A string that specifies the layer name to attach with. If more than one layer name is provided, the command will use the first layer in the list that exists in the drawing.
Return Values If attach measured gross was successful, returns T. If the operation failed for any reason, returns nil. Example Attach the current drawing's measured gross area to the largest boundary on the GRMV-19 layer: (CiAttachMGross "GRMV-19")
T
Attach the current drawing's measured gross area to layer1 if it is on the drawing, layer2 if it is on the drawing, or layer3 if it is on the drawing, in that order. If no layers are present, the command fails and return nil.
Command: (CiAttachMGross "layer1" "layer2" "layer3"
T
- CiLogin
- Logs in to the server environment specified by name using the username and password.
Table 12. (CiLogin environment username password) Arguments environment A string that specifies what environment to log in to. The name is case-sensitive.
username A string that specifies the username to log in with. The name is case-sensitive.
password A string that specifies the password to log in with. The name is case-sensitive.
Return Values If login succeeds, returns T. If login failed for any reason, returns nil. Example Log in to the environment with the name "Default" using the username "caduser", and password "password".
Command: (CiLogin "Default" "caduser" "password")
T
- CiLogout
- Logs out of the server.
(CiLogout)
Return values: Returns T if successful, nil otherwise.
- CiPublish
- Publishes the current drawing.
(CiPublish)
Return values: Returns T if successful, nil otherwise.
- CiSync
- Sync the areas of the current drawing with the server.
(CiSync)
Return values: Returns T if successful, nil otherwise.
- CiUpload
-
Given a mapping name (e.g. the space mapping), scan the boundaries with the specified boundary layer name with text specified by the text layer name, and upload (create or update) the records specified by the mapping to the server. The list of mappable fields.
Table 13. (CiUpload childMappingName boundaryLayername textLayername listRequiredFieldSublists [listMappableFieldSublists]) Arguments childMappingName A string that specifies which mapping to upload the boundaries for.
boundaryLayername A string that specifies the layer to look for boundaries to upload
textLayername A string that specifies the layer to look for the name of the boundaries.
listRequiredFieldSublists A list of sublists that specify the required field default values, and the layer to look for a value to upload. It will have the following form:
((fieldkey defaultvalue [layername]...)...)
Arguments (continued) Subarguments
fieldkey The unique identifier for a required field.
defaultvalue The value to upload by default
layername Optionally, the layer name can be used to override the default value with the value from the layer. If more than one layer is specified, the first layer on the list that is present on the drawing will be used.
The number of arguments for listRequiredFieldSublists depends on the number of actual required fields for the current drawing's application and the child mapping specified. The command CiQueryRequiredFields will return the field keys that must be specified in this parameter. Extra field sublists will be accepted, and any that do not match a field key will be ignored. Since all required fields must have a default value specified, this command will fail if this parameter does not have at least one fieldkey specified for each required field. If there are no required fields, then this parameter will be ignored. You can specify expecting no required fields with an empty list ().
listMappableFieldSublists A list of sublists that specify the mappable field and layer to upload values from. It will have the following form:
([(fieldkey layername [layername]...)]...)
Arguments (continued) Subarguments
fieldkey The unique identifier for a mappable field.
layername The layer name to look for a value to upload. If more than one layer is specified, the first layer on the list that is present on the drawing will be used.
Each mappable field upload is optional. The command CiQueryMappableFields will return the field keys that may be specified in this parameter. Extra field sublists will be accepted, and any that do not match a field key will be ignored.
Return Values If upload succeeds, returns T. If upload failed, returns nil. Example Let us assume the following is true:
Command: (CiQueryRequiredFields "Facilities Management-Primary" "triSpace Mapping") ("triGeneral_triCurrentSpaceClass_triNameTX")
Command: (CiQueryMappableFields "Facilities Management-Primary" "triSpace Mapping") ("triGeneral_triDetails_triMainFaxTX" "triGeneral_triGeneral_triDescriptionTX")
Also assume the current drawing is attached with the "Facilities Management-Primary" application definition.
The following command uploads all the "spaces" (as specified in the "triSpace Mapping") that are enclosed by boundaries on the "PL-23" layer, with the space name determined by the text on the "name" layer. This will set the required "space class" field to "Office" if text on the "SC-44" layer is not in the boundary, or the value of the "SC-44" layer text field if it is. If there is text for the "faxLayer" in the boundary, the "Main Fax" field will be populated by the layer contents. If the layer "layer1" exists on the drawing, the "Description" field will be populated by that layer contents, and if not, the "faxLayer" will determine the contents of the "Description" field.
Command: (CiUpload "triSpace Mapping" "PL-23" "name" '(("triGeneral_triCurrentSpaceClass_triNameTX" "Office" "SC-44")) '(("triGeneral_triDetails_triMainFaxTX" "faxLayer") ("triGeneral_triGeneral_triDescriptionTX" "layer1" "faxLayer")))
T
Example (continued) Same command as above, but we do not want to populate the "Description" field at all.
Command: (CiUpload "triSpace Mapping" "PL-23" "name" '(("triGeneral_triCurrentSpaceClass_triNameTX" "Office" "SC-44")) '(("triGeneral_triDetails_triMainFaxTX" "faxLayer")))
T
Same command as above, but we do not want to populate any of the mappable fields:
Command: (CiUpload "triSpace Mapping" "PL-23" "name" '(("triGeneral_triCurrentSpaceClass_triNameTX" "Office" "SC-44")))
T
Example (continued) Suppose we have the following instead:
Command: (CiQueryRequiredFields "Facilities Management-Primary" "triSpace Mapping")
T
Then there are no required fields.
Command to upload with no required fields or mappable field updates:
Command: (CiUpload "triSpace Mapping" "PL-23" "name")
T
Same as above but with a mappable field specified. Here, since the 5th parameter is the mappable fields argument, we have to fill in the empty required field argument:
Command: (CiUpload "triSpace Mapping" "PL-23" "name" () '(("triGeneral_triDetails_triMainFaxTX" "faxLayer")))
T
Query Commands
Commands that return information, as opposed to executing an action, will be shown here.
- CiQueryMappableFields
- Returns the mappable field keys for a given application definition and mapping.
Table 14. (CiQueryMappableFields applicationDefinition mapping) Arguments applicationDefinition A string that specifies the application definition.
mapping A string that specifies the mapping.
Return Values The field keys for each mappable field on the mapping. If the keys are empty, returns T. If the command fails for any reason, returns nil. Example Command to list the field keys for the mappable fields in the "Facilities Management-Primary" application definition and the "triSpace Mapping". In this example, the mappable fields for "triSpace Mapping" is the main fax field, and the description field. The results show the tab name, section name, and field name, which uniquely identifies those fields on the triSpace form.
Command: (CiQueryMappableFields "Facilities Management-Primary" "triSpace Mapping") ("triGeneral_triDetails_triMainFaxTX" "triGeneral_triGeneral_triDescriptionTX")
- CiQueryRequiredFields
- Returns the required field keys for a given application definition and mapping.Note: For CiUpload, all these fields must have a default value specified.
Table 15. (CiQueryRequiredFields applicationDefinition mapping) Arguments applicationDefinition A string that specifies the application definition. mapping A string that specifies the mapping.
Return Values The field keys for each required field specified by the mapping's form. If the keys are empty, returns T. If the command fails for any reason, returns nil. Example Command to list the field keys for the required fields in the "Facilities Management-Primary" application definition and the "triSpace Mapping". In this example, the required field for "triSpace Mapping" is the current use space class field. The results show the tab name, section name, and field name, which uniquely identifies the field on the triSpace form.
Command: (CiQueryRequiredFields "Facilities Management-Primary" "triSpace Mapping") ("triGeneral_triCurrentSpaceClass_triNameTX")