importing 3 dxf files to blocks

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
dobidobido
Newbie Member
Posts: 4
Joined: Tue Apr 03, 2018 2:56 pm

importing 3 dxf files to blocks

Post by dobidobido » Fri Nov 02, 2018 4:55 pm

Hello im curious if i can import three dxf files on seperate blocks by using import file. I ve checked paste,edit and import scripts and wrote the below code,

Code: Select all

...
   var sourceDocument = RDocument.getClipboard();
     var sourceDi = new RDocumentInterface(sourceDocument);
     var offset = new RVector(0,0);

     di.setCurrentBlock("D1);
     var op = new RPasteOperation(sourceDocument);
     sourceDi.importFile('a.dxf')
     op.setOffset(offset);
     di.applyOperation(op);

     di.setCurrentBlock("D2");
     var op2 = new RPasteOperation(sourceDocument);
     sourceDi.importFile('b.dxf')
     op2.setOffset(offset);
     di.applyOperation(op2);

     di.setCurrentBlock("D3);
     var op4 = new RPasteOperation(sourceDocument);
     sourceDi.importFile('c.dxf')
     op4.setOffset(offset);
     di.applyOperation(op4);

it basicly puts a.dxf on block D1, a.dxf & b.dxf on block D2 and a.dxf,b.dxf and c.dxf on block D3 however i want a on D1, b on D2 and c on D3. I know i need to change sourceDocument each time a file is imported but i couldnt figured it out. How can i change the sourceDocument so that the previous imported file is not imported on the current Block.
Thanks and apologies for taking your time.

dobidobido
Newbie Member
Posts: 4
Joined: Tue Apr 03, 2018 2:56 pm

Re: importing 3 dxf files to blocks

Post by dobidobido » Fri Nov 02, 2018 11:04 pm

Briefly, i mean how can i implement deleteClipboard operation? is there any examples sample scripts using it?

dobidobido
Newbie Member
Posts: 4
Joined: Tue Apr 03, 2018 2:56 pm

Re: importing 3 dxf files to blocks

Post by dobidobido » Sat Nov 03, 2018 12:57 pm

any help or update?

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

Re: importing 3 dxf files to blocks

Post by andrew » Mon Nov 05, 2018 12:11 pm

I'd recommend to create a separate offscreen document for each item:

Code: Select all

var sourceDocument = new RDocument(new RMemoryStorage(), new RSpatialIndexSimple());

Post Reply

Return to “QCAD 'How Do I' Questions”