Interactive Scripting to Interactive COGO [SOLVED]

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Interactive Scripting to Interactive COGO [SOLVED]

Post by Joseph1916 » Mon Jul 31, 2023 8:24 pm

I am revisiting this topic, it is a central issue.

Script ExMyMinimal.js and ExMyMinimal.xml simply seems to wait for a "grid" input point.......

Can anyone spot an issue why the problems?
Last edited by Joseph1916 on Mon Aug 07, 2023 6:24 pm, edited 7 times in total.

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting

Post by Joseph1916 » Mon Jul 31, 2023 8:29 pm

Operating System: Linux Ubuntu 22.04
QCAD Version: 3.28.1

indentation appears in text file ExMyMinimal.js and ExMyMinimal.iu

After POST my indentation is remover. How come?

Thanks.
Joseph1916
Last edited by Joseph1916 on Thu Aug 03, 2023 6:51 pm, edited 1 time in total.

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Interactive Scripting to Interactive COGO

Post by CVH » Tue Aug 01, 2023 5:33 am

Joseph1916 wrote:
Mon Jul 31, 2023 8:24 pm
Can anyone spot an issue why the problems?
Hardly. :shock: :!:
Remarked in several of your latest post is the use of some kind of HTML type tags:
e.g:

Code: Select all

</e></QUOTE>
came back with a Parse Error. <br/>
<br/>
While the js file: <br/>
Why not using plain text?

Code: Select all

came back with a Parse Error.

While the js file:
You also quoted the XML and the JS code what make it even harder to read.
It is common to use a code panel for such things ... Select the code portion in your topic and use the '</>' button.

The functional UI I can retrieve is:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExMyMinimal</class>
<widget class="QWidget" name="ExMyMinimal">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="RadiusLabel">
<property name="text">
<string>&amp;Radius:</string>
</property>
<property name="buddy">
<cstring>Radius</cstring>
</property>
</widget>
</item>
<item>
<widget class="RMathLineEdit" name="Radius">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>RMathLineEdit</class>
<extends>QLineEdit</extends>
<header>RMathLineEdit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Without the proper indentations but they don't really matter. :wink:

It looks like:
Joseph1916-UI.png
Joseph1916-UI.png (3.25 KiB) Viewed 10021 times

The naming of this plain text file should be: ExMyMinimal.ui

And now the JS script .... :roll: ... With indentations, it is common to use 4 spaces for a tab in QCAD.

Code: Select all

include("scripts/EAction.js");

function ExMyMinimal(guiAction) {
    EAction.call(this, guiAction);

    this.pos = undefined;
    this.radius = undefined;

    this.setUiOptions("ExMyMinimal.ui");
}

ExMyMinimal.prototype = new EAction();

ExMyMinimal.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);

    var di = this.getDocumentInterface();
    di.setClickMode(RAction.PickCoordinate);
};

ExMyMinimal.prototype.pickCoordinate = function(event, preview) {
    this.pos = event.getModelPosition();

    if (preview) {
        this.updatePreview();
    }
    else {
        this.applyOperation();
    }
};

ExMyMinimal.prototype.getOperation = function(preview) {
    if (isNull(this.pos) || isNull(this.radius)) {
        return undefined;
    }

    var doc = this.getDocument();

    var op = new RAddObjectOperation();
    var circle = new RCircle(this.pos, this.radius);
    op.addObject(shapeToEntity(doc, circle));
    return op;
};

ExMyMinimal.prototype.slotRadiusChanged = function(v) {
    this.radius = v;
    this.updatePreview();
};

ExMyMinimal.init = function(basePath) {
    var action = new RGuiAction(qsTr("&Minimal Example"), RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setScriptFile(basePath + "/ExMyMinimal.js");
    action.setGroupSortOrder(100000);
    action.setSortOrder(0);
    action.setWidgetNames(["ExamplesMenu"]);
};
The naming of this plain text file should be: ExMyMinimal.js

Can't detect any coding error with this ... It draws a circle with the radius from the UI at the indicated position ...
... Probably you tried to implement this with all the unrelated/faulty tags in place.

Please use a plain text editor.
On windows I can advice Notepad++ using the formatting language 'JavaScript' and using the Unix EOL.
I am sure there will be Linux alternatives.

And please use plain text to enter topics. :wink:

Regards,
CVH

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting to Interactive COGO

Post by Joseph1916 » Tue Aug 01, 2023 4:18 pm

Hello CVH,

Lots to consume with your posting..... How do i ensure my Posts are in plain Text? Is that an option? Anyway, now using Genome Text Editor, hopefully in will resolve some of the problems.

I have limited programming background and especially with MS Windows and the Internet(i.e. JavaScript, HTML, etc.)

I will attempt to solve my problems one by one. The code is still not executing correctly. RESOLVED
CODE is now executing.

Thanks for all your help !!

Joseph1916
Last edited by Joseph1916 on Thu Aug 03, 2023 6:55 pm, edited 1 time in total.

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting to Interactive COGO

Post by Joseph1916 » Tue Aug 01, 2023 4:43 pm

I have solved some problems :-) However, code executing properly :-)


Joseph1916
Last edited by Joseph1916 on Thu Aug 03, 2023 6:57 pm, edited 2 times in total.

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting to Interactive COGO

Post by Joseph1916 » Tue Aug 01, 2023 4:45 pm

I have the code working !!
Last edited by Joseph1916 on Thu Aug 03, 2023 6:59 pm, edited 1 time in total.

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Interactive Scripting to Interactive COGO

Post by CVH » Tue Aug 01, 2023 4:53 pm

Joseph1916 wrote:
Tue Aug 01, 2023 4:18 pm
How do i ensure my Posts are in plain Text?
I enter ... type ... this in the reply box and it comes out as plain text, right?
The same is true when you do that in the text box for new topics.

ExMyMinimal.ui and ExMyMinimal.js should both be located in a folder called ExMyMinimal somewhere under the script folder.

For example: ... QCAD/scripts/Misc/Examples/ExMyMinimal where the 3 dots represent your QCAD installation path.

Regards,
CVH

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Interactive Scripting to Interactive COGO

Post by CVH » Tue Aug 01, 2023 5:07 pm

Joseph1916 wrote:
Tue Aug 01, 2023 4:45 pm
NO I have not !!
What have you not ...?

So far the second version of your code is exactly the same as the previous and as mine except indentations, except as code in a code panel.
One edit own posts, see the button with the pencil in it.

Regards,
CVH

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting to Interactive COGO

Post by Joseph1916 » Wed Aug 02, 2023 6:17 pm

CVH ;

Sorry for the delay with this reply...... What I was referring to was earlier Post. I was basically chatting to myself. Disregard that statement.

I do not see how you get the "white code box" to reflect Code? Knowing how to do that could help me communicate !!

Regarding my current Script, let me do additional investigations, as to the source for the failing Script. We know it is on my side !!

Thanks for your support !

Joseph1916
Last edited by Joseph1916 on Thu Aug 03, 2023 3:09 pm, edited 1 time in total.

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Interactive Scripting to Interactive COGO

Post by CVH » Wed Aug 02, 2023 6:53 pm

Joseph1916 wrote:
Wed Aug 02, 2023 6:17 pm
I do not see how you get the "white code box" to reflect Code? Knowing how to do that could help me communicate !!
When you are writing a topic you can copy/paste some code text to include it.
Then select the pasted code lines.
At the top of the text box there is a ribbon with buttons.
With the code lines selected hit the '</>' button.
Similar for setting text bold, italic, underlined ...

This is code

Will be displayed on Preview or Submit as:

Code: Select all

This is code
In text form a code box starts with 'code' between squared brackets and ends at '/code' between squared brackets.
It speaks for itself that I couldn't include these brackets in the above sentence. :wink:

Or you could hit the code button an then insert the lines of code between the two formatting tags.

Regards,
CVH

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting to Interactive COGO

Post by Joseph1916 » Wed Aug 02, 2023 6:56 pm

My mistake. The Dialog was at the top..... Did not expect that....... SUCCESS.... Sorry I took such time..... We can all move on...

Joseph1916

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Interactive Scripting to Interactive COGO

Post by CVH » Wed Aug 02, 2023 6:59 pm

Joseph1916 wrote:
Wed Aug 02, 2023 6:56 pm
We can all move on...
Yes, please, and maybe you want to declutter this topic by editing your own posts. :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”