load default template

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
Post one question per topic.
Post Reply
User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

load default template

Post by J-J » Mon Mar 05, 2012 12:42 pm

I need some help with scripting: I have made a drawing with a number of predefined layers that I use as a template for a new drawing. How can I replace the default drawing that is opened upon QCAD start-up with this template?

User avatar
andrew
Site Admin
Posts: 5710
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Mon Mar 05, 2012 3:38 pm

There's no preference for the default template (at this point).

A possible script solution would be:

template.js:

Code: Select all

var mainWindow = RMainWindowQt.getMainWindow();
var doc = mainWindow.getDocument();
var di = mainWindow.getDocumentInterface();

di.importFile("template.dxf");
di.regenerateScenes();
di.autoZoom();
doc.setFileName("");
template.dxf: The template drawing

Starting QCAD:

Code: Select all

./qcad -exec ./template.js

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

start up template

Post by J-J » Mon Mar 05, 2012 10:14 pm

Thanks for your quick reply. When I type the start up code in the command line, it is ver2.2.2 that gets launched, not 3.0
Is it possible to make a short cut in the traditional Windows way?
(Win 7 -64)

User avatar
andrew
Site Admin
Posts: 5710
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Tue Mar 06, 2012 9:42 am

Under Windows you'd probably have to write a batch file that changes into the correct QCAD directory and then launches QCAD with the necessary parameters.

I'm not much help with this since I've never done anything with Windows batch files..

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

default template

Post by J-J » Wed Mar 07, 2012 8:43 am

I got some positive results with this batch file:
@echo off
path C:\Program Files (x86)\QCAD-3\qcad-3.0.0-rc3-prof-win32
qcad -exec ./template.js

Windows did not like the "./" before qcad

To get the cmd file to work I had to locate the file "template.js" on the desktop...I am not an expert with Windows!
Thanks for your help.

uwezi
Newbie Member
Posts: 3
Joined: Fri Aug 13, 2010 8:52 pm

Re: load default template

Post by uwezi » Tue Nov 20, 2012 7:57 pm

Under Windows 7 I placed the template.dxf and the script startup.js in the program directory of QCad.

In order to start QCad with these settings, just right-click on the shortcut in the start-menu, choose Properties and change the Target. In my case the correct setting is

Code: Select all

"C:\Program Files\QCAD Professional3\qcad.exe" -exec .\startup.js
Uwe.

Post Reply

Return to “QCAD 'How Do I' Questions”