![]() |
QCAD
Open Source 2D CAD
|
This module defines the QCAD Simple API in ECMAScript. The QCAD Simple API is meant to simplify common tasks such as adding entities. To use the QCAD Simple API in your scripts, include the file simple.js in your script: More...
Functions | |
void | addArc (void center, void radius, void startAngle, void endAngle, void reversed) |
Adds an arc to the drawing. More... | |
void | addCircle (void center, void radius) |
Adds a circle to the drawing. More... | |
void | addEntity (void entity) |
Adds the given REntity to the drawing using layer and attributes as set by the entity. More... | |
void | addLayer (void name, void colorName, void linetypeName, void lineWeight) |
Adds a layer to the drawing. More... | |
void | addLine (void startPoint, void endPoint) |
Adds a line to the drawing. More... | |
void | addObject (void obj) |
Adds the given RObject to the drawing. More... | |
void | addPoint (void position) |
Adds a point to the drawing. More... | |
void | addPolyline (void points, void closed, void relative) |
Adds a polyline to the drawing. More... | |
void | addShape (void shape, void color, void linetype, void lineweight) |
Adds the given RShape to the drawing as a new entity using current layer and attributes. More... | |
void | addShapes (void shapes) |
Adds the given RShapes to the drawing as new entities using current layer and attributes. More... | |
void | addSimpleText (void text, void position, void height, void angle, void font, void vAlign, void hAlign, void bold, void italic) |
Adds a simple text to the drawing. More... | |
void | addSpline (void points, void closed) |
Adds a spline to the drawing. More... | |
void | addXLine (void startPoint, void directionVector) |
Adds an infinite line to the drawing. More... | |
void | autoZoom () |
Auto zoom. More... | |
void | createDocument () |
Creates an (off-screen) document. More... | |
void | createDocumentInterface () |
Creates an (off-screen) document with a document interface that can be used to import / export to / from files or graphics scenes and views. More... | |
void | deleteObject (void obj) |
Deletes the given RObject from the drawing. More... | |
void | disableInput () |
Disables the main application window to prevent user input. More... | |
void | enableInput () |
Enables the main application window to allow user input. More... | |
void | endTransaction () |
Ends a transaction. More... | |
void | getDocument () |
Returns the current RDocument or undefined. More... | |
void | getDocumentInterface () |
Returns the current RDocumentInterface or undefined. More... | |
void | getDouble (void title, void prompt, void value, void prec, void lower, void upper) |
Display an input dialog box and return a double. More... | |
void | getGraphicsView () |
Returns the current or last active RGraphicsView. More... | |
void | getInt (void title, void prompt, void value, void step, void lower, void upper) |
Display an input dialog box and return an integer. More... | |
void | getIntersectionPoints (void e1, void e2, void limited) |
Returns intersection points between the two given entities or shapes. More... | |
void | getItem (void title, void prompt, void items, void idx, void splitStr) |
Display a combo drop down box and return item. More... | |
void | getMainWindow () |
Returns a pointer to the main application window (RMainWindowQt). More... | |
void | getOperation () |
Returns the current operation if we are in a transaction or a new operation. More... | |
void | getText (void title, void prompt, void txt) |
Display an input dialog box and return string. More... | |
void | getTransactionDocument () |
Returns the RDocument the current transaction applies to or the current document or undefined. More... | |
void | getTransactionDocumentInterface () |
Returns the RDocumentInterface the current transaction applies to or the current document interface or undefined. More... | |
void | hasLayer (void name) |
Checks if the given layer exists. More... | |
void | isInputEnabled () |
Returns true if user input is enabled. More... | |
void | lengthen (void entity, void start, void amount) |
Lengthens of shortens the given entity or shape. More... | |
void | mirror (void e, void axis) |
Mirrors the given entity or shape at the given axis. More... | |
void | move (void e, void offset) |
Moves the given entity or shape by the given offset. More... | |
void | paste (void docSource, void diDestination, void offset, void scale, void rotation, void flipHorizontal, void flipVertical, void toCurrentLayer, void overwriteLayers, void overwriteBlocks) |
Pastes the given document into the current document or into the second given document. More... | |
void | rotate (void e, void angle, void center) |
Rotates the given entity or shape by the given angle around the given center. More... | |
void | scale (void e, void factor, void focusPoint) |
Scales the given entity or shape by the given factor with the given focus point. More... | |
void | setCurrentColor (void color) |
Sets the current color for newly added entities. More... | |
void | setCurrentLayer (void layerName) |
Sets the current layer to the given layer. More... | |
void | sleep (void d) |
Sleeps for the indicated time in milliseconds. More... | |
void | startTransaction (void d) |
Starts a transaction. More... | |
void | trim (void trimEntity, void trimClickPos, void limitingEntity, void limitingClickPos, void trimBoth) |
Trims the given entity / entities or shape(s). More... | |
void | update () |
Keeps the user interface up to date during long operations. More... | |
void | warning (void msg) |
Prints a warning to stdout. More... | |
void | zoomTo (void p1, void p2, void p3, void p4, void p5) |
Zooms to the given entity. More... | |
This module defines the QCAD Simple API in ECMAScript. The QCAD Simple API is meant to simplify common tasks such as adding entities. To use the QCAD Simple API in your scripts, include the file simple.js in your script:
void addArc | ( | void | center, |
void | radius, | ||
void | startAngle, | ||
void | endAngle, | ||
void | reversed | ||
) |
void addCircle | ( | void | center, |
void | radius | ||
) |
void addEntity | ( | void | entity | ) |
Adds the given REntity to the drawing using layer and attributes as set by the entity.
void addLayer | ( | void | name, |
void | colorName, | ||
void | linetypeName, | ||
void | lineWeight | ||
) |
Adds a layer to the drawing.
void addLine | ( | void | startPoint, |
void | endPoint | ||
) |
void addObject | ( | void | obj | ) |
Adds the given RObject to the drawing.
void addPoint | ( | void | position | ) |
void addPolyline | ( | void | points, |
void | closed, | ||
void | relative | ||
) |
Adds a polyline to the drawing.
p | Array of type [ [ x, y, bulge, relative ], ..., [ ... ] ] or [ [ vector, bulge, relative ], ..., [ ... ] ] Where: x: X coordinate y: Y coordinate vector: RVector with position of vertex bulge: Bulge for next segment after vertex, defaults to 0.0. relative: True if this vector's coordinates are relative to the previous coordinates, defaults to false. |
closed | True for an implicitly closed polyline. Default is false. |
relative | True to treat all coordinates as relative. The first coordinate is always absolute. Default is false. |
void addShape | ( | void | shape, |
void | color, | ||
void | linetype, | ||
void | lineweight | ||
) |
void addShapes | ( | void | shapes | ) |
Adds the given RShapes to the drawing as new entities using current layer and attributes.
void addSimpleText | ( | void | text, |
void | position, | ||
void | height, | ||
void | angle, | ||
void | font, | ||
void | vAlign, | ||
void | hAlign, | ||
void | bold, | ||
void | italic | ||
) |
Adds a simple text to the drawing.
text | Text string. |
position | position |
height | Text height (defaults to 1) |
angle | Text angle (defaults to 0) |
font | Font (defaults to "standard") |
vAlign | Vertical alignment (defaults to RS.VAlignTop) |
hAlign | Horizontal alignment (defaults to RS.HAlignLeft) |
bold | True for bold text (TTF fonts only) |
italic | True for italic text (TTF fonts only) |
void addSpline | ( | void | points, |
void | closed | ||
) |
void addXLine | ( | void | startPoint, |
void | directionVector | ||
) |
void autoZoom | ( | ) |
Auto zoom.
void createDocument | ( | ) |
Creates an (off-screen) document.
Such a document can be filled with objects and saved to disk, pasted into the current document, etc.
void createDocumentInterface | ( | ) |
Creates an (off-screen) document with a document interface that can be used to import / export to / from files or graphics scenes and views.
void deleteObject | ( | void | obj | ) |
Deletes the given RObject from the drawing.
void disableInput | ( | ) |
Disables the main application window to prevent user input.
void enableInput | ( | ) |
Enables the main application window to allow user input.
void endTransaction | ( | ) |
Ends a transaction.
void getDocument | ( | ) |
Returns the current RDocument or undefined.
void getDocumentInterface | ( | ) |
Returns the current RDocumentInterface or undefined.
void getDouble | ( | void | title, |
void | prompt, | ||
void | value, | ||
void | prec, | ||
void | lower, | ||
void | upper | ||
) |
Display an input dialog box and return a double.
title | - Title of dialog box |
prompt | - Prompt to display. |
value | - Value to display in the input box (Default = 0.0). |
prec | - Spin button precision (Default = 1). |
lower | - minimum value (Default = -2147483647) |
upper | - maximum value (Default = 2147483647) |
void getGraphicsView | ( | ) |
Returns the current or last active RGraphicsView.
void getInt | ( | void | title, |
void | prompt, | ||
void | value, | ||
void | step, | ||
void | lower, | ||
void | upper | ||
) |
Display an input dialog box and return an integer.
title | - Title of dialog box |
prompt | - Prompt to display. |
value | - Value to display in the input box (Default = 0). |
step | - Spin box step value (Default = 1). |
lower | - minimum value (Default = -2147483647) |
upper | - maximum value (Default = 2147483647) |
void getIntersectionPoints | ( | void | e1, |
void | e2, | ||
void | limited | ||
) |
Returns intersection points between the two given entities or shapes.
e1 | First entity, entity ID or shape. |
e2 | Second entity, entity ID or shape. |
limited | True to only return intersection points that lay on the given entities or shapes (visible intersections). |
void getItem | ( | void | title, |
void | prompt, | ||
void | items, | ||
void | idx, | ||
void | splitStr | ||
) |
Display a combo drop down box and return item.
title | - Title of dialog box |
prompt | - Prompt to display. |
items | - List of items to display in the combo box. |
idx | - index of item to display (Default = 0) |
splitStr | - Character or string to split the items (Default = ",") |
void getMainWindow | ( | ) |
Returns a pointer to the main application window (RMainWindowQt).
void getOperation | ( | ) |
Returns the current operation if we are in a transaction or a new operation.
void getText | ( | void | title, |
void | prompt, | ||
void | txt | ||
) |
Display an input dialog box and return string.
title | - Title of dialog box |
prompt | - Prompt to display. |
txt | - Text to display in the input box. |
void getTransactionDocument | ( | ) |
Returns the RDocument the current transaction applies to or the current document or undefined.
void getTransactionDocumentInterface | ( | ) |
Returns the RDocumentInterface the current transaction applies to or the current document interface or undefined.
void hasLayer | ( | void | name | ) |
Checks if the given layer exists.
void isInputEnabled | ( | ) |
Returns true if user input is enabled.
void lengthen | ( | void | entity, |
void | start, | ||
void | amount | ||
) |
Lengthens of shortens the given entity or shape.
entity | Entity, entity ID or shape to lengthen |
start | True to extend at start point, false for end point |
amount | Amount to lengthen or negative value to shorten |
void mirror | ( | void | e, |
void | axis | ||
) |
Mirrors the given entity or shape at the given axis.
e | Entity, entity ID or shape. |
void move | ( | void | e, |
void | offset | ||
) |
void paste | ( | void | docSource, |
void | diDestination, | ||
void | offset, | ||
void | scale, | ||
void | rotation, | ||
void | flipHorizontal, | ||
void | flipVertical, | ||
void | toCurrentLayer, | ||
void | overwriteLayers, | ||
void | overwriteBlocks | ||
) |
Pastes the given document into the current document or into the second given document.
docSource | RDocument to paste |
docDestination | RDocument to paste into (or undefined for current document) |
offset | Offset RVector or [x,y] array |
scale | Scale factor |
rotation | Rotation angle in degrees |
flipHorizontal | True to flip horizontally |
flipVertial | True to flip vertically |
toCurrentLayer | Paste all entities to the current layer of the target document |
overwriteLayers | Overwrite existing layers in the target document with layers from the source document |
overwriteBlocks | Overwrite existing blocks in the target document with blocks from the source document |
void rotate | ( | void | e, |
void | angle, | ||
void | center | ||
) |
void scale | ( | void | e, |
void | factor, | ||
void | focusPoint | ||
) |
void setCurrentColor | ( | void | color | ) |
Sets the current color for newly added entities.
void setCurrentLayer | ( | void | layerName | ) |
Sets the current layer to the given layer.
layerName | Layer name or ID. |
void sleep | ( | void | d | ) |
Sleeps for the indicated time in milliseconds.
void startTransaction | ( | void | d | ) |
Starts a transaction.
This can increase performance when adding multiple entities. Entities are added in one transaction when endTransaction is called.
d | RDocument or RDocumentInterface to apply the transaction to (defaults to current document). |
void trim | ( | void | trimEntity, |
void | trimClickPos, | ||
void | limitingEntity, | ||
void | limitingClickPos, | ||
void | trimBoth | ||
) |
Trims the given entity / entities or shape(s).
trimEntity | Entity, entity ID or shape to trim |
trimClickPos | Position clicked when choosing trim entity. |
limitingEntity | Entity, entity ID or shape that limits the trimming. |
limitingClickPos | Position clicked when choosing limiting entity. |
trimBoth | True to trim both entities. |
void update | ( | ) |
Keeps the user interface up to date during long operations.
User input must be disabled using disableInput before calling update.
void warning | ( | void | msg | ) |
Prints a warning to stdout.
void zoomTo | ( | void | p1, |
void | p2, | ||
void | p3, | ||
void | p4, | ||
void | p5 | ||
) |
Zooms to the given entity.
Returns the bounding box of the given entity or undefined.