Odd behaviour for Block Attributes

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Odd behaviour for Block Attributes

Post by BertMv » Mon Oct 03, 2022 2:42 pm

I may do something wrong, not sure. Just checking if this is a bug, a feature or my stupidity.

I have layer 0 set to compatibility.

I made some blocks with attributes, everything on layer 0, and saved them in a library. When I insert this block (from the library) in a drawing, it always gets placed on layer 0 (not the current, active layer).
This in itself is odd, but now when I place a second instance of this block from the Block List, the lines do get placed on the active layer, but the attributes still get placed on layer 0.

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

Re: Odd behaviour for Block Attributes

Post by CVH » Mon Oct 03, 2022 6:24 pm

BertMv wrote:
Mon Oct 03, 2022 2:42 pm
When I insert this block (from the library) in a drawing, it always gets placed on layer 0 (not the current, active layer).
When you insert a library item that is a block then 2 things happen:
A: The Block is created just the same way it was defined.
B: A Block Reference is placed where you insert it and that on the active layer.

The entities that make up your block are thus still on Layer 0.
The Block Reference should reside on the active layer.

This would answer why your Block Attributes reside on Layer 0.
https://www.qcad.org/rsforum/viewtopic. ... 509#p36506

Regards,
CVH

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Mon Oct 03, 2022 7:17 pm

Thank you for answering. I understand what you say, but I think I'm missing something.
Does this mean that everytime I place a library item (block) I need to move it to the proper layer afterwards? And when placing a block with attributes from the block list I need to do the same for those attributes?
This would seem a very error-prone way of working not to mention extra work. I cannot imagine it is intended behaviour, so I must misunderstand something?

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Odd behaviour for Block Attributes

Post by ryancousins » Mon Oct 03, 2022 7:40 pm

BertMv,

I tried walking through your same steps and couldn't get the same thing to happen. Let me know if I'm doing something different than you did:

1. create some geometry on layer 0
2. turn that geometry into a block.
3. add one or more attributes to that block, also on layer 0.
4. create a library item from that block.

5. open a new file and import the file from your library
6. This creates a new block in the block list of your new file. This is the block definition, and it belongs to layer 0 just like the original one from the other file.
7. This also created a reference to that block in the model space of your new file. This reference to the block should become part of whatever layer is active.

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

Re: Odd behaviour for Block Attributes

Post by CVH » Mon Oct 03, 2022 8:38 pm

BertMv wrote:
Mon Oct 03, 2022 7:17 pm
Does this mean that everytime I place a library item (block) I need to move it to the proper layer afterwards?
Not at all.
Where a Block definition lives is all by your choise, here it was created on layer 0.
Same for Attributes, again layer 0.

Where you put the Block Reference is also by your choise, the active layer.

Remark that you can do several things at the side when you are about to insert a library item.
Changing the active layer, create a new layer, renaming and so on.
It is even possible to draw some lines or other entities in between.
All up to the point that you actually place the library item.

There is a major difference between a Block and a Block Reference.
A Block is a collection of entities, a Block Reference is an entity itself.
Inserting a Block or a library item as Block is not copying the entities that make up the Block.
One only places a reference to the Block.
In the case of a library item the Block itself is also created if it didn't exist already.


Regards,
CVH

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Mon Oct 03, 2022 10:35 pm

ryancousins wrote:
Mon Oct 03, 2022 7:40 pm
I tried walking through your same steps and couldn't get the same thing to happen. Let me know if I'm doing something different than you did:
Hi,
Thank you for those steps. It helped me understand what I did wrong. What I did was, after creating a block from the geometry, I deleted the geometry and placed a block reference on layer 0. I'm not at my computer right now, but I assume this is what is causing the problem. Basically I am importing a reference to a block. I am still getting used to the different workflow/mechanics between autocad and qcad, Some things are obvious, others not so much.

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Mon Oct 03, 2022 10:39 pm

CVH wrote:
Mon Oct 03, 2022 8:38 pm
There is a major difference between a Block and a Block Reference.
A Block is a collection of entities, a Block Reference is an entity itself.
Thank you. I worked professionally with AutoCAD from 1991 till 2012, so I am very familiar with blocks, definitions and references. I think I figured it out as per the above post. What threw me was that creating a block in qcad doesn't turn the actual elements into a block but it merely creates a definition. So I replced that with the block (or so I thought) but what I did (stupidly) was replace it with a reference.
I assumed that creating a library item was similar (in behaviour) to WBLOCK (Write Block) in AutoCAD, but it seems there is a (subtle) difference.

Thanks for the help :)

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

Re: Odd behaviour for Block Attributes

Post by CVH » Tue Oct 04, 2022 7:33 am

BertMv wrote:
Mon Oct 03, 2022 10:39 pm
Thank you. I worked professionally with AutoCAD from 1991 till 2012, so I am very familiar with blocks, definitions and references.
Sorry, we could not know that. :wink:
But I still think that there is some misunderstanding.
BertMv wrote:
Mon Oct 03, 2022 2:42 pm
when I place a second instance of this block from the Block List, the lines do get placed on the active layer,
Inserting a Block from the Block List doesn't places the lines on the active layer, a Block Reference is created on that layer.
BertMv wrote:
Mon Oct 03, 2022 10:39 pm
What threw me was that creating a block in qcad doesn't turn the actual elements into a block but it merely creates a definition.
When you create a Block from geometry in Model Space (BC) the geometry is stored in a Block, aka the Block definition.
The geometry itself is indeed replaced by a Block Reference in Model Space.
Deleting this reference and re-inserting the Block as a new Block Reference gives you just the same situation.
(It only has another handle and/or drawing order :wink: )
BertMv wrote:
Mon Oct 03, 2022 10:35 pm
What I did was, after creating a block from the geometry, I deleted the geometry and placed a block reference on layer 0.
Here the geometry was already replaced with a Block Reference.


Further, a library item itself is inserted as a Block with the library item (file-)name as Block name.
Meaning that all the geometry in Model Space of the library item dxf file is stored as a Block definition with that name.
That includes Block References.
Inserting a library item with internal Blocks References creates A: The item Block Reference, B: The item Block, C: The referenced Blocks.
A is placed where you insert the item, B & C are placed as they were in the library item.

There is a subtle difference when we Import a dxf, then we can choose if all is imported as one new Block or as entities.
Again, entities can be Block References and Blocks can include other Block References.

As last, there is also a difference when the Library item has the same name as the internal referenced Block.

Regards,
CVH

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Tue Oct 04, 2022 10:07 am

Okay, so I did some testing today.

1. I created a block with an attribute (named Block-With-Attribute) and turned it into a library (named My_Library)
2. I created a block with an attribute (named block-with-same-name-as-library) and turned it into a library (named block-with-same-name-as-library)

A. When importing My_Library, this gets placed on the active layer, but without access to the attributes in the property editor, I need to remove it and replace it with Block-With-Attributes (Understandable since it references My_Library instead of the Block-With-Attribute)
B. When importing block-with-same-name-as-library, this does give me access to the attributes without having to replace it, but it gets placed on Layer 0 so I need to change its layer (or remove it and replace it from the block-list, same as under A.)

So unless I am still doing something wrong, either way I need to do an extra step?

See screenshots

So basically, my question is this: How do I import a block so I actually place a block-reference in the active layer directly? (Without having to use predefined layers in the block itself)

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Odd behaviour for Block Attributes

Post by ryancousins » Tue Oct 04, 2022 2:24 pm

BertMv

Just to be sure, when you're creating your original geometry and attribute, you're doing all of that in Layer 0?

If I create some geometry and and attribute in layer 0, then select that geometry and attribute and choose "make library item", and then load that library file into a new file, it creates a new definition in my block list and also has me place a reference to that block right away, and I can place that on whichever layer I want and it reflects that. It sounds like that is not the case for you?

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Tue Oct 04, 2022 3:04 pm

Yeah. Everything on layer 0. And I get the behaviour as explaind in my previous post.

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Odd behaviour for Block Attributes

Post by ryancousins » Tue Oct 04, 2022 4:11 pm

I will keep experimenting. So far I have tried three different approaches:

1. selecting the raw geometry and attribute in the original file and making it a library item.
2. Making the raw geometry and attribute into a block first and then selecting the reference that is newly placed in the main model space and creating a library item from that.
3. Making the raw geometry and attribute into a block and selecting the definition while in that block's own model space and making that a library item.

I would assume all of these methods should all result in the same thing once we're dealing with importing the file from the library into a new file.

In each case and I'm always able to place the block in the active layer. There have been a couple times while messing around where my block will NOT reflect the active layer in the new file but I can't seem to find a pattern yet of what I must have done differently in those cases EXCEPT when I didn't create my original geometry and attribute in layer 0.

BertMv
Junior Member
Posts: 11
Joined: Fri Sep 30, 2022 11:39 am

Re: Odd behaviour for Block Attributes

Post by BertMv » Tue Oct 04, 2022 4:35 pm

Not at my computer anymore for the day. I'll see if I can make a screencast tomorrow. Thanks for your efforts

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

Re: Odd behaviour for Block Attributes

Post by Husky » Tue Oct 04, 2022 7:23 pm

Hi,
ryancousins wrote:
Tue Oct 04, 2022 4:11 pm
So far I have tried three different approaches:

1. selecting the raw geometry and attribute in the original file and making it a library item.
2. Making the raw geometry and attribute into a block first and then selecting the reference that is newly placed in the main model space and creating a library item from that.
3. Making the raw geometry and attribute into a block and selecting the definition while in that block's own model space and making that a library item.

I would assume all of these methods should all result in the same thing once we're dealing with importing the file from the library into a new file.
Nope!
to 1. - correct approach
to 2. + 3. incorrect approach

Why?
If you create a Library Item (BT) directly from geometry it will built the block on its own as part of the tool procedure!

If you built a Library item from an already existing block you'll built unnoticed a stacked block. Basically the block you created first in your drawing will be overplayed by an additional block created automatically by using the "Create Library Item" tool. Inserting such a Library item lead to unexpected behavior during inserting the item because QCAD isn't anymore able to read the 1. block information like e.g. Attributes - only the 2. block information. However - If you insert such a block and explode it then you will get again access to the 1. block information ...
ryancousins wrote:
Tue Oct 04, 2022 4:11 pm
I will keep experimenting. So far I have tried three different approaches:
I recommend to do further experimenting only based on approach 1. :wink:
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..."

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Odd behaviour for Block Attributes

Post by ryancousins » Tue Oct 04, 2022 7:40 pm

Hey Husky,

Typically I would only use method #1 and I wouldn't advocate for anyone to try methods #2 or #3. I was just trying every different variation I could think of to try and reproduce what is happening to BertMV. :wink:

Post Reply

Return to “QCAD Troubleshooting and Problems”