<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: layer attributes for block references in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/layer-attributes-for-block-references/m-p/9044385#M5135</link>
    <description>&lt;P&gt;Objects in a block reference inherit most of their properties from the way they are defined in a block table record, with the exception of certain types of attribute definitions/references.&amp;nbsp; So for example, if a polyline is assigned layer "123" when the block is created, the line will be drawn using the properties of layer "123" for all instances of a specific block when inserted into a drawing.&amp;nbsp; It is possible to have objects within a block inherit the general properties of the block reference, this is done by assigning the objects within a block the value of ByBlock for a particular object property or drawing objects on Layer 0 before adding them to a block.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="BlkRef_ByBlock_ByLayer.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/680590i1E6297A1064FC562/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BlkRef_ByBlock_ByLayer.png" alt="BlkRef_ByBlock_ByLayer.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P style="clear: both;"&gt;&lt;BR /&gt;If you want to change the layer in which a polyline is drawn on for all instances of a block inserted into a drawing, you would open that particular block table record for reach and then iterate to find the polyline object and then modify that object.&lt;BR /&gt;&lt;BR /&gt;The following is a basic code sample that should get you started with how to change the layer of a entity in a block definition using ObjectARX:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Get the current database
AcDbDatabase *pDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();

// Open the Block Table for read-only
AcDbBlockTable *pBlockTable;
pDb-&amp;gt;getSymbolTable(pBlockTable, AcDb::kForRead);

// Get the Model Space block
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable-&amp;gt;getAt("MyBlockDef", pBlockTableRecord, AcDb::kForWrite);
pBlockTable-&amp;gt;close();

// Create a new block iterator that will be used to
// step through each object in the current space
AcDbBlockTableRecordIterator *pItr;
pBlockTableRecord-&amp;gt;newIterator(pItr);
	
// Create a variable AcDbEntity type which is a generic 
// object to represent a Line, Circle, Arc, among other objects
AcDbEntity *pEnt;

// Step through each object in the block
for (pItr-&amp;gt;start(); !pItr-&amp;gt;done(); pItr-&amp;gt;step())
{
    // Use pEnt-&amp;gt;isA()-&amp;gt;name() to look for a specific object type

    // Get the entity and open it for write
    pItr-&amp;gt;getEntity(pEnt, AcDb::kForWrite);

    // Display the class name for the entity before
    pEnt-&amp;gt;setLayer("123");
    pEnt-&amp;gt;close();
}
	
// Close the current space object
pBlockTableRecord-&amp;gt;close();

// Remove the block iterator object from memory
delete pItr;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2019 16:19:09 GMT</pubDate>
    <dc:creator>ambrosl</dc:creator>
    <dc:date>2019-09-24T16:19:09Z</dc:date>
    <item>
      <title>layer attributes for block references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/layer-attributes-for-block-references/m-p/9039574#M5134</link>
      <description>&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN&gt;I create blocks / references with my plugins.&lt;/SPAN&gt; &lt;SPAN&gt;all blocks have the same layer, for example "layer for block".&lt;/SPAN&gt; But if I&lt;SPAN&gt; open the block, I would like to have another layer for the polylines.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;H&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN&gt;ow do I set a layer for a created line in block reference?&lt;/SPAN&gt; &lt;SPAN&gt;can someone send me a code example?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN&gt;basicaly i want to know how the layer is set in property panel after double click (open block reference) on polyline&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 19:55:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/layer-attributes-for-block-references/m-p/9039574#M5134</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-22T19:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: layer attributes for block references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/layer-attributes-for-block-references/m-p/9044385#M5135</link>
      <description>&lt;P&gt;Objects in a block reference inherit most of their properties from the way they are defined in a block table record, with the exception of certain types of attribute definitions/references.&amp;nbsp; So for example, if a polyline is assigned layer "123" when the block is created, the line will be drawn using the properties of layer "123" for all instances of a specific block when inserted into a drawing.&amp;nbsp; It is possible to have objects within a block inherit the general properties of the block reference, this is done by assigning the objects within a block the value of ByBlock for a particular object property or drawing objects on Layer 0 before adding them to a block.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="BlkRef_ByBlock_ByLayer.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/680590i1E6297A1064FC562/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BlkRef_ByBlock_ByLayer.png" alt="BlkRef_ByBlock_ByLayer.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P style="clear: both;"&gt;&lt;BR /&gt;If you want to change the layer in which a polyline is drawn on for all instances of a block inserted into a drawing, you would open that particular block table record for reach and then iterate to find the polyline object and then modify that object.&lt;BR /&gt;&lt;BR /&gt;The following is a basic code sample that should get you started with how to change the layer of a entity in a block definition using ObjectARX:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Get the current database
AcDbDatabase *pDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();

// Open the Block Table for read-only
AcDbBlockTable *pBlockTable;
pDb-&amp;gt;getSymbolTable(pBlockTable, AcDb::kForRead);

// Get the Model Space block
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable-&amp;gt;getAt("MyBlockDef", pBlockTableRecord, AcDb::kForWrite);
pBlockTable-&amp;gt;close();

// Create a new block iterator that will be used to
// step through each object in the current space
AcDbBlockTableRecordIterator *pItr;
pBlockTableRecord-&amp;gt;newIterator(pItr);
	
// Create a variable AcDbEntity type which is a generic 
// object to represent a Line, Circle, Arc, among other objects
AcDbEntity *pEnt;

// Step through each object in the block
for (pItr-&amp;gt;start(); !pItr-&amp;gt;done(); pItr-&amp;gt;step())
{
    // Use pEnt-&amp;gt;isA()-&amp;gt;name() to look for a specific object type

    // Get the entity and open it for write
    pItr-&amp;gt;getEntity(pEnt, AcDb::kForWrite);

    // Display the class name for the entity before
    pEnt-&amp;gt;setLayer("123");
    pEnt-&amp;gt;close();
}
	
// Close the current space object
pBlockTableRecord-&amp;gt;close();

// Remove the block iterator object from memory
delete pItr;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 16:19:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/layer-attributes-for-block-references/m-p/9044385#M5135</guid>
      <dc:creator>ambrosl</dc:creator>
      <dc:date>2019-09-24T16:19:09Z</dc:date>
    </item>
  </channel>
</rss>

