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:
<code>
Type
enum RShape::Type
Enumerator
Unknown
Point
Line
Arc
Circle
Ellipse
Polyline
Spline
Triangle
XLine
Ray
</code>
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.
How to use qcad enumeration objects in a script?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Active Member
- Posts: 25
- Joined: Thu Sep 07, 2023 1:17 am
- Location: USA
- andrew
- Site Admin
- Posts: 8774
- Joined: Fri Mar 30, 2007 6:07 am
Re: How to use qcad enumeration objects in a script?
In a script, you can use
Code: Select all
RShape.Line
RShape.Arc
...
-
- Premier Member
- Posts: 4919
- Joined: Wed Sep 27, 2017 4:17 pm
Re: How to use qcad enumeration objects in a script?
Hi,
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
I think that the main difference is RShape's vs REntity'smrhickman53 wrote: ↑Thu Nov 14, 2024 5:40 pmThe 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.
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
-
- Premier Member
- Posts: 4919
- Joined: Wed Sep 27, 2017 4:17 pm
Re: How to use qcad enumeration objects in a script?
For the record: Menu .. Import/Export .. Draw From CSV creates drawing entities based on commands in a CSV.mrhickman53 wrote: ↑Thu Nov 14, 2024 5:40 pmMy 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.
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