Greetings once again!
A few questions:
1 - I want to build a code function that allows me to select an entity on the drawing board, the same way as if I had clicked on the entity itself. I assume there is a library function for this, using, perhaps, the ID of the entity. could an example be provided?
2 - I want to make a function that allows me to change the direction of an entity. For example: Line starts in [0;0] and ends in [10;10]. I want to be able to change it from [10;10] to [0;0] with a click. I don't think that merely changing the coordinates is the best way to achieve this. I have noticed that there are two functions in QCad library "direction1()" and "direction2()" that may have something to do with this, but I fail to understand how they work and if they are what I am looking for.
3 - I note that when I create entities in QCad, there is a small red dot that appears on points of interest as I work. I would like to know how to make this dot appear in points of my choosing, through code.
As usual, I use javascript.
Thank you very much.
[Solved]Selecting entities and direction
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.
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
[Solved]Selecting entities and direction
Last edited by Ghost_of_Magellan on Thu May 05, 2016 10:12 am, edited 1 time in total.
Re: Selecting entities and direction
RDocumentInterface::selectEntityGhost_of_Magellan wrote:1 - I want to build a code function that allows me to select an entity on the drawing board, the same way as if I had clicked on the entity itself. I assume there is a library function for this, using, perhaps, the ID of the entity. could an example be provided?
Reversible entities have a function reverse: RLineEntity::reverse(), e.g. myLine.reverse();Ghost_of_Magellan wrote:2 - I want to make a function that allows me to change the direction of an entity. For example: Line starts in [0;0] and ends in [10;10]. I want to be able to change it from [10;10] to [0;0] with a click. I don't think that merely changing the coordinates is the best way to achieve this. I have noticed that there are two functions in QCad library "direction1()" and "direction2()" that may have something to do with this, but I fail to understand how they work and if they are what I am looking for.
As usual, such a change would have to be applied using an operation.
RDocumentInterface::setRelativeZeroGhost_of_Magellan wrote:3 - I note that when I create entities in QCad, there is a small red dot that appears on points of interest as I work. I would like to know how to make this dot appear in points of my choosing, through code.
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: Selecting entities and direction
Hmm. So it seems I can't just do
The functions won't understand the int value, it seems. That, or I'm trying to put the values into the wrong object, though i have attempted to put it into entityIds and entity and the debuger returned the error: "Result of expression 'entity.selectEntity' [undefined] is not a function."
I believe it is safe to say that I have not yet grasped the class and object variables as I should.
I have also tried:
within the cycle to no avail.
May I have a code example?
I apologize for wasting your time.
Thank you, andrew.
Code: Select all
doc = EAction.getDocument();
entityIds = doc.queryAllVisibleEntities();
//Cycle
entity = doc.queryEntity(entityIds[i]);
// End Cycle
doc.selectEntity(55, true);
I believe it is safe to say that I have not yet grasped the class and object variables as I should.
I have also tried:
Code: Select all
doc.selectEntity(entity.getId(), true);
May I have a code example?
I apologize for wasting your time.
Thank you, andrew.
Re: Selecting entities and direction
It could be that you are selecting entities but the selection is not reflected on the display. Try using the document interface instead (EAction.getDocumentInterface()). A document knows nothing about the views that are attached to it and cannot update them.
See also:
http://www.qcad.org/doc/qcad/latest/dev ... asses.html
See also:
http://www.qcad.org/doc/qcad/latest/dev ... asses.html
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: Selecting entities and direction
Thank you andrew, the RDocumentInterface worked nicely. And the documentation you provided, though too complicated for me, helped me get a sense of how the doc-interface-graphical connections in QCad work.
I tried to use the same logic with the setRelativeZero but ended up short. I made some attempts
I suppose the proper way to do it would initiate a RVector variable with the contents of the point in either int or string?
docInterface = EAction.getDocumentInterface(); docInterface.selectEntity(55, true);The 55 here, being just an example. Now I can select any entity in order of its ID.
I tried to use the same logic with the setRelativeZero but ended up short. I made some attempts
var tst = tst.RVector(10,10,0,true); docInterface.setRelativeZero(tst); /* Result of expression 'tst' [undefined] is not an object.*/ docInterface.setRelativeZero(10,10,0); /* <global>() at -1 */ docInterface.setRelativeZero(10,10,0,true); /* <global>() at -1 */Among many other examples, some so ridiculous that I'm simply too embarassed to post here =\
I suppose the proper way to do it would initiate a RVector variable with the contents of the point in either int or string?
Re: Selecting entities and direction
var v = new RVector(10,10); docInterface.setRelativeZero(v);or short:
docInterface.setRelativeZero(new RVector(10,10));
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: Selecting entities and direction
This is exactly it!
Thank you very much, andrew.
Thank you very much, andrew.