Running Scripts [SOLVED]

Use this forum for all posts and questions about the free QCAD Community Edition version 3

Moderator: andrew

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

Running Scripts [SOLVED]

Post by Joseph1916 » Sat Jul 15, 2023 6:14 pm

Operating System: Ubuntu 22.04
Program: QCAD 3.28.1 Community Edition
Testing out my Ubuntu 22.04 and QCAD Community Edition.

Entered Misc Drop Down menu > Script Shell appeared properly seemed to execute one line at a time FINE

Entered Misc Menu > Run Script Open > Dialog Box Appeared > Selected Script File > But nothing happened.

I'm on Community Edition, Is that an issue??
Last edited by Joseph1916 on Sun Aug 06, 2023 12:59 am, edited 1 time in total.

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

Re: Running Scripts

Post by CVH » Sat Jul 15, 2023 6:52 pm

Joseph1916 wrote:
Sat Jul 15, 2023 6:14 pm
But nothing happened
Have you an example script to share ... :?:
You my also PM 'Personal Message' the example if that is more convenient for you.

Regards,
CVH

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

Re: Running Scripts

Post by Joseph1916 » Sat Jul 15, 2023 11:47 pm

Its the example provided: (without the comments)

a=7; b=6;
phi=0.2*Math.PI;
step=Math.PI/256;
w=100;
h=100;
v=[];
for (t=0.0; t<Math.PI*2; t+=step) {
// compute next x,y coordinate:
x = w * Math.sin(a*t + phi);
y = h * Math.sin(b*t);

// append coordinate to our array of coordinates:
v.push([x,y]);
}
addSpline(v, true);
autoZoom();


Joseph1916

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

Re: Running Scripts

Post by CVH » Sun Jul 16, 2023 5:23 am

Joseph1916,
Joseph1916 wrote:
Sat Jul 15, 2023 6:14 pm
Entered Misc Drop Down menu > Script Shell appeared properly seemed to execute one line at a time FINE
One can paste several lines of code to the bottom line of the Script Shell in one go.
These are executed the same way as if they where in a script file.
For saved scripts the file extension *.js is even not mandatory.
Joseph1916 wrote:
Sat Jul 15, 2023 6:14 pm
I'm on Community Edition, Is that an issue??
Yes and no.
addSpline(...); is part of the Simple API and draws a fitpoint spline.
CE only supports control point splines.

You could replace addSpline(...) by addPolyline(...)
Then you get an approximation by line-segments what looks about the same there the points cloud is dense enough.

To be able to draw fitpoint splines the only advice is to upgrade to QCAD PRO :wink: or to use the trial version.

Regards,
CVH

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

Re: Running Scripts

Post by Joseph1916 » Sun Jul 16, 2023 5:56 pm

Hi CVH;

SOLVED !!! I worked on my own attempts, They were not the issue, but the addPolyline( ... ) did the trick.

On to learn more, and I feel I will go to the Professional after I get more experience ......

Thanks for the strong support...

Joseph1916

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

Re: Running Scripts

Post by Joseph1916 » Sun Jul 16, 2023 9:10 pm

CVH,

Hey

My objective with QCAD is to create a a 2d JavaScript array database of Point values that will be assigned Point Numbers contained in Column 1 of the 2d array. Column 2 3 and 4 will be the XYZ of the respective Points. Column 5 would be a description.

I was a Survey Engineer, with no Software but Civil 3D, and that is not for Surveyors, And its price is outrageous.

Joseph1916, Retired Surveyor

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

Re: Running Scripts

Post by CVH » Sun Jul 16, 2023 11:04 pm

Joseph1916,
QCAD PRO comes with a powerful script developed by Andrew: Import Points with Labels ...
Have a look here:
https://qcad.org/en/tutorial-importing- ... s-from-csv

Various kinds of points can later be stored to use as coordinate input data for creating splines/polylines ... For inserting blocks ... And so on.
https://qcad.org/en/tutorial-reusing-drawing-positions

Exporting things in a drawing to CSV can already be done by an OS Command Line tool dwg2csv:
https://qcad.org/en/products/qcad-command-line-tools
That CSV data may require some polishing up. :wink:

Regards,
CVH

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

Re: Running Scripts

Post by Joseph1916 » Wed Aug 02, 2023 7:43 pm

Scripts supporting ExMyMinimal.iu Code:

<?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>
Last edited by Joseph1916 on Thu Aug 03, 2023 7:12 pm, edited 1 time in total.

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

Re: Running Scripts

Post by CVH » Thu Aug 03, 2023 5:48 am

Joseph1916,
Joseph1916 wrote:
Wed Aug 02, 2023 7:43 pm
.... See the topic above ....
I can not comprehend how and why this will not work for you ... :shock:
Below is the exact same text as in the post above.
Simply copied whole your topic content and pasted it in the reply topic text box:

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>
Seems to look well formatted as code when I do it.
Sure, indentations are removed in your post as do all leading spaces in plain text.
That won't happen if the text is in a code box. :wink:

Regards,
CVH

Post Reply

Return to “QCAD Community Edition”