Wednesday, October 22, 2014

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.



CIA – Command Line API Specification
AutoLISP Limitations
AutoLISP does not naturally support a “long” datatype, yet TRIRIGA 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
CiAttachDrawing

Attaches the current drawing to the server.
(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.
Examples
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.
(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.
Examples
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.
(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.
Examples
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.
(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.
Examples
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
Returnes T if successful, nil otherwise.


CiPublish
Publishes the current drawing.
(CiPublish)
Return Values
Returnes T if successful, nil otherwise.

CiSync
Sync the current drawing to the server.
(CiSync)
Return Values
Returnes 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
(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]...)...)
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]...)]...)
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.
Examples
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 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
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
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.
(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.
Examples
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 that for CiUpload, all these fields must have a default value specified.
(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.
Examples
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")

Taken from https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20TRIRIGA1/page/AutoCAD%20Command%20Line%20API%20Specification

No comments:

Post a Comment