How to use qcad enumeration objects in a script?

My general goal is to create shapes from information in a csv file and store the shapes in an array till I am ready to create a document and place entities into the document. I am currently working with RTextData, RPolyline and RLine. While it is not strictly necessary for my application I have been experimenting with querying the references I’ve stored in an array in order to determine the type of object is being referenced. All RShapes have a method, getShapeType() that returns a value from the enumeration:

Type
enum RShape::Type
Enumerator
Unknown
Point
Line
Arc
Circle
Ellipse
Polyline
Spline
Triangle
XLine
Ray

How is this enumeration accessed in a script? RShape.getShapeType() returns a value from this enumeration, but I would like to test against the key, not the value. How would this be performed?

The RTextData uses getType(), which returns a value from a different enumeration, which is unfortunate, but a separate issue. I would expect the same procedure to access the key associated with the value would apply.

If the answer to this is obvious from the documentation, what documentation am I not apparently aware of?

Thanks.

In a script, you can use

RShape.Line
RShape.Arc
...

Hi,

I think that the main difference is RShape’s vs REntity’s

Shapes are low-level mathematical representations.
You will find them in the Math module, these are nothing compared with drawing entities.
A text or a dimension and onther are part of the Entity module.

It is not uncommon to use the functions in library.js to diversify.
For example:

  • isLineEntity(obj)
  • isArcEntity(obj)
  • isTextEntity(obj)
    Or
  • isLineShape(obj)
  • isArcShape(obj)

Regards,
CVH

For the record: Menu .. Import/Export .. Draw From CSV creates drawing entities based on commands in a CSV.
DrawFromCSV is part of the open source.

It doesn’t really store intermediates in an array.
If all validates well, an new entity is added to an operation, continuing with the next entry.
In the end all new objects are added by applying the operation.

Regards,
CVH