Export a Block to dxf? [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

Export a Block to dxf? [SOLVED]

Post by Joseph1916 » Thu Jul 27, 2023 8:30 pm

Is subject possible with QCAD 3.28.1? I believe its possible with AutoCAD..... I would be interested to work on it......
Last edited by Joseph1916 on Sat Aug 05, 2023 11:08 pm, edited 1 time in total.

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4943
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Export a Block to dxf?

Post by Husky » Thu Jul 27, 2023 9:12 pm

If you save a block as a library item then this block is saved as a dxf ... 8)
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

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

Re: Export a Block to dxf?

Post by CVH » Thu Jul 27, 2023 9:54 pm

Husky wrote:
Thu Jul 27, 2023 9:12 pm
If you save a block as a library item then this block is saved as a dxf
Please explain this further, It is not possible to select a block from the Block List and save that.

One can select a single Block Reference entity and create a library item from that entity (BT), no need for a reference position.
Still, this creates a DXF with a block definition and a Block Reference entity at (0,0) in Model_Space.
Downside: One can not 'export' an unused Block aka only the block definition.

Another problem is that one can not 'import' one or a set of unused blocks ...
... Yet 'unused' but intended to start using them in the drawing at hand.

Regards,
CVH

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

Re: Export a Block to dxf?

Post by Joseph1916 » Fri Jul 28, 2023 8:28 pm

<t>OS: Ubuntu 22.04<br/>
QCAD: 3.28.1<br/>
<br/>
I saw a post about set Reference Point, I believe that would help. I only have one good drawing of my own. Others are from a Surveyor that will reference both to real world coordinate Values and then mix with 0,0 type values that could be a 100's of miles away. Its a problem for Surveyors. I, at least, need to be able to control reference values x and y. For engineers and surveyors the Northing and Easting. Otherwise I am guessing at the real base point. Which is QCAD's Reference.<br/>
<br/>
Does that make sense to you? Exporting Blocks as singular entities with x and y values is the best solution.</t>

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

Re: Export a Block to dxf?

Post by CVH » Sat Jul 29, 2023 7:39 am

Joseph,

In scripting if you have a block reference in the document then one can set/alter its position with:

Code: Select all

var blockRef;    // A reference to a block reference entity (RBlockReferenceEntity)
var position;     // A valid position (RVector)
blockRef.setPosition(position);
// One has to recast that to the document to actually change the position of the entity
When selected a block reference entity has a single selection marker (little blue square) ... The reference point.
The GUI alternative would be setting/moving the block reference entity marker at a specified place or ...
... by changing the position values in the Property Editor.
Joseph1916 wrote:
Fri Jul 28, 2023 8:28 pm
Otherwise I am guessing at the real base point.
Beside a position in Model_Space block references have a rotation angle and scale factors.
A block (the block definition) may have an origin set different from (0,0) ... An inverse offset.
You need to evaluate all these values/factors to figure out where and how a copy of the block entities is located in Model_Space.

I am used to create my blocks near their origin without an offset.
What I encounter lately with blocks provided by a customer is that the entities in the block are noway near their origin.
If I add such a block (BI) then QCAD shows a cross-hair but no visible preview of the block itself.
The block entities are there but indeed miles away from the cross-hair ... The reference position.
From a screen video I understand that ACAD displays the block content at the cursor.

On editing such a block for the first time QCAD will auto zoom to the block content.
All fine but one needs to understand that now the block origin is far out of view.


About Northing and Easting:
QCAD zero degree is right, counting counter clock wise ... 90 degrees is up.
This is the standard Math base.

QCAD doesn not provide in a UCS where one could shift, tilled, or mirror the coordinate plane.
Thus North = 0.0° = Up as X and CW is not an option for the time being.
But one can enter coordinates this way and QCAD will translate them.
Joseph1916 wrote:
Fri Jul 28, 2023 8:28 pm
Exporting Blocks as singular entities with x and y values is the best solution.
Yes and no ... Not precisely.
First you need to explode (XP) the block to its individual entities.
Best preformed on a block reference inserted at the origin with no offset.
Then cut/copy the result of the explosion to a new document keeping reference points (RT/RC).
Save this new document to a new DXF file.
One can then import (Ctrl+Shift+I) such a DXF file as block (First option of the Import Options Toolbar)
QCAD will propose the file name without extension as block name.
On importing it creates the block definition on the fly and places a block reference entity at your cursor.

Do you intend to script exporting blocks that way?

Regards,
CVH

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

Re: Export a Block to dxf?

Post by Joseph1916 » Sat Jul 29, 2023 10:54 pm

First you need to explode (XP) the block to its individual entities.
Best preformed on a block reference inserted at the origin with no offset.
Then cut/copy the result of the explosion to a new document keeping reference points (RT/RC).
Save this new document to a new DXF file.
Thank you for the reply. Excellent!!.. Now using that above procedure.

I will be meeting with a Computer Scientist tomorrow morning going over this issue and QCAD in general.

Joseph1916

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

Re: Export a Block to dxf?

Post by CVH » Sun Jul 30, 2023 8:39 am

Joseph1916 wrote:
Sat Jul 29, 2023 10:54 pm
going over this issue and QCAD in general
I don't see an issue with QCAD ... I see odd or incorrect created blocks.

I presume that (some) other Apps create a block from entities with the drawing origin as reference point.
QCAD allows for indicating a reference point when creating a block from selected entities (BC).
That could again be (0,0) absolute of course but we tend to give the block a meaningful origin.

Regards,
CVH

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

Re: Export a Block to dxf?

Post by Joseph1916 » Mon Jul 31, 2023 7:04 pm

I don't see an issue with QCAD
Well said I do not either. My issue with BLOCK is closed.

Thank you for your support.

Joseph1916
:-)

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”