Hi All
Years ago I used to make very basic lisp files to do very very basic tasks, can anyone help me with this
Attached is the lisp routine :- and before anyone says yes there is probably a better way to make the lsp file
and also return osnaps to previous settings
All i want to do is select and Arc or even better window select arcs and turn them into circles.
There is a problem when sometimes exploding blocks circles become 1 arc with a start point 0
and end point 360, Qcad displays these arcs and one can assume they are circles, but when loading
the dxf into CNC software it displays as a Dot, likewise in AutoCad a dot / zero length arc
Thanks for any help in advance
Cheers
John
PS I didn't know how to insert it as code it kept saying Spam Detected , here is a screenshot
if you don't want to download the zip file..
Help with making a script file
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
-
- Premier Member
- Posts: 473
- Joined: Mon Sep 30, 2019 6:21 am
- Location: Melbourne - Australia
Help with making a script file
Last edited by John Hyslop on Wed Feb 03, 2021 8:23 am, edited 2 times in total.
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]
Re: Help with making a script file
Hi John,
Already a while QCAD doesn't explode circles to 1 full Arc but in two 2 semi full Arcs.
A Polyline that is.
Recently, explosion of circles is made optional in App.Prefs.
Below you'll find a script for full Arcs to Circles:
Regards.
CVH
Already a while QCAD doesn't explode circles to 1 full Arc but in two 2 semi full Arcs.
A Polyline that is.
Recently, explosion of circles is made optional in App.Prefs.
Below you'll find a script for full Arcs to Circles:
Regards.
CVH
Code: Select all
// Full Arcs to Circles script by CVH
var doc = getDocument();
var di = getDocumentInterface();
var arcsCollected = [];
// Retrieve the selection:
var ids = doc.querySelectedEntities();
// Terminate without selection:
if (ids.length === 0) {
EAction.handleUserWarning("Nothing Selected! Script terminated.");
return;
}
// Filter full Arcs from selection:
for (var i=0; i<ids.length; i++) {
// Get entity from the document:
var entity = doc.queryEntity(ids[i]);
// Collect when exist and is full Arc:
if (!isNull(entity)){
if (isArcEntity(entity)) {
var arcSweep = Math.abs(entity.getSweep());
if (RMath.fuzzyAngleCompare(arcSweep, Math.PI*2.0)) {
arcsCollected.push(ids[i]);
}
}
}
}
// Terminate without full Arcs in selection:
if (arcsCollected.length === 0) {
EAction.handleUserWarning("No full Arc entities selected! Script terminated.");
return;
}
// Setup an operation:
var operation = new RModifyObjectsOperation();
operation.setText("Full Arcs to circles");
// Process collected Arcs
for (var i=0; i<arcsCollected.length; i++) { //Cycle collected Arcs
// Get full Arc from the document:
var fullArc = doc.queryEntity(arcsCollected[i]);
// Create a new Circle entity:
var newCircle = new RCircleEntity(
doc,
new RCircleData(
fullArc.getCenter(),
fullArc.getRadius()
)
);
// Add the new Circle to the operation:
operation.addObject(newCircle, false, true); // NOTuseCurrentAttributes, DOforceNew
// Mark the full Arc to delete:
operation.deleteObject(fullArc);
} // Loop Arcs
// Apply all modifications:
di.applyOperation(operation);
// Finished:
var msg = "Created " + arcsCollected.length + " Circle entity/ies."
EAction.handleUserInfo(msg);
EAction.handleUserMessage("Script ended.");
return;
Last edited by CVH on Wed Feb 03, 2021 9:26 am, edited 3 times in total.
-
- Premier Member
- Posts: 473
- Joined: Mon Sep 30, 2019 6:21 am
- Location: Melbourne - Australia
Re: Help with making a script file
Thanks CVH
I'll try later, Yes i just tested explodes to 2 arcs that's fine for cnc, I must of seen this in a previous version of Qcad...
Cheers
John
I'll try later, Yes i just tested explodes to 2 arcs that's fine for cnc, I must of seen this in a previous version of Qcad...
Cheers
John
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]
-
- Premier Member
- Posts: 473
- Joined: Mon Sep 30, 2019 6:21 am
- Location: Melbourne - Australia
Re: [ Solved ] Help with making a script file
Hi CVH
As you know I don't know much about Java scripting
I copied your text and saved it in a file a2c.js
made a folder under Scripts/Misc/c2a
and placed it there but Qcad won't run unless I remove it
Could you explain how and where i put this file so I can use it in the Qcad UI ? is it a Java script file?
I don't know
Cheers
John
As you know I don't know much about Java scripting
I copied your text and saved it in a file a2c.js
made a folder under Scripts/Misc/c2a
and placed it there but Qcad won't run unless I remove it
Could you explain how and where i put this file so I can use it in the Qcad UI ? is it a Java script file?
I don't know
Cheers
John
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]
Re: Help with making a script file
Sure,
It is not a GUI action ...
... with a button.
(If you want that ... )
Make selection.
Open Script Shell (GE)
Copy all.
Paste.
Saved as a *.js file
Make selection.
Run Script (XC) ...
Regards,
CVH
PS: Herrinbore seed for BHT ready
-
- Premier Member
- Posts: 473
- Joined: Mon Sep 30, 2019 6:21 am
- Location: Melbourne - Australia
Re: Help with making a script file
Herringbone.. I bet I won't understand the equation and not be able to add
Looking forward to the maths, I bet it's a beauty..
Cheers
John
Looking forward to the maths, I bet it's a beauty..
Cheers
John
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]