<?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: how to select certain objects in a block reference in model space using c# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143361#M20859</link>
    <description>&lt;P&gt;I am sorry, I just find that What I selected is another entity(wipeout)&amp;nbsp; which I created to combine with the original block reference. I will move the wipeout under the original blocke reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I am working on a project in which user can select the edges of a block reference, then the addin can create (by the coordinates of the edges)and combine a wipeout with the block reference to make the block reference move over other entites.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 09:13:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-11-13T09:13:29Z</dc:date>
    <item>
      <title>how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9138819#M20850</link>
      <description>&lt;P&gt;&amp;nbsp;I am working on a project that a user should select the border lines of the block reference. However, when I hover my mouse onto the block reference, the whole block is selected.&amp;nbsp; I just want to select a line of the block reference?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PromptEntityOptions options = new PromptEntityOptions(message);
 options.SetRejectMessage("\n selected target is not supported");
 options.AddAllowedClass(typeof(Line), true);
PromptEntityResult result = ed.GetEntity(options);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I do not want to explode the block reference and recombine them.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 09:40:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9138819#M20850</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-11T09:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9139325#M20851</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the Editor.GetNestedEntity() method to get the line.&lt;/P&gt;
&lt;P&gt;The objectId is the one the line within the block definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            using (var tr = db.TransactionManager.StartTransaction())
            {
                PromptNestedEntityResult result;
                while (true)
                {
                    result = ed.GetNestedEntity("\nSelect a line within a block reference: ");

                    // user cancelled
                    if (result.Status != PromptStatus.OK)
                    {
                        return;
                    }

                    // check if the selected object is a line
                    if (result.ObjectId.ObjectClass.DxfName == "LINE")
                    {
                        // check if the line is nested
                        if (result.GetContainers().Length == 0)
                        {
                            ed.WriteMessage("\nThe selected line is not nested in a block reference.");
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        ed.WriteMessage("\nThe selected entity is not a line.");
                    }
                }

                // open the line of the block defintion 
                var line = (Line)tr.GetObject(result.ObjectId, OpenMode.ForRead);

                // compute the transformation matrix from the containers
                var xform = result.GetContainers()
                    .Select(id =&amp;gt; (BlockReference)tr.GetObject(id, OpenMode.ForRead))
                    .Select(br =&amp;gt; br.BlockTransform)
                    .Aggregate((m1, m2) =&amp;gt; m2 * m1);

                // transform the line start and ensd points
                var startPoint = line.StartPoint.TransformBy(xform);
                var endPoint = line.EndPoint.TransformBy(xform);
                ed.WriteMessage($"\nStart point: {startPoint}\nEnd point: {endPoint}");
                tr.Commit();
            }&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Nov 2019 14:18:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9139325#M20851</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-11-11T14:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9139410#M20852</link>
      <description>&lt;P&gt;Because BlockReference is a SINGLE entity, your code, which only allows to select a Line, obviously does not work. To programmatically select something inside a block definition that is presented/visible in a BlockReference, you use PromptNestedEntityOptions/Editor.GetNestedEntity()/PromptNestedEntityResult to find out what is selected. However, if you want to provide visual hint on what is selected (such as highlight), it would be up to you to do that, which is not a trivial task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These 2 articles might be what you want, or at least, helpful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2019/08/select-multiple-nested-entities-1.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2019/08/select-multiple-nested-entities-1.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2019/08/selecting-multiple-nested-entities-2-of.html" target="_blank"&gt;https://drive-cad-with-code.blogspot.com/2019/08/selecting-multiple-nested-entities-2-of.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 14:53:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9139410#M20852</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-11-11T14:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9140439#M20853</link>
      <description>&lt;P&gt;why should I transform the start point and end point of the line? Is the coodinates of the start point and end point of the line different from the ones in WCS?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 02:00:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9140439#M20853</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-12T02:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9140651#M20854</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;why should I transform the start point and end point of the line? Is the coodinates of the start point and end point of the line different from the ones in WCS?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As I said, PromptNestedResult.ObjectId returns the ObjectId of the line in the block definition (BlockTableRecord), so we have to transform its coordinates with the BlockReference.BlockTransform transformation matrix* to get the WCS coordinates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* more accurately with the combination of all transformations of all containers in case of nested blocks.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 06:19:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9140651#M20854</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-11-12T06:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9142803#M20855</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 00:44:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9142803#M20855</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-13T00:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143178#M20856</link>
      <description>&lt;P&gt;I really appreciate your solution since your code works.&amp;nbsp; But I have one more question, If the entity I want to select is nested in the block reference of another block reference (the block reference depth is two), then your program will prompt that "the entity your selected is not a line". So is there a way to select a line nested in two or more block references?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 07:23:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143178#M20856</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-13T07:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143292#M20857</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I really appreciate your solution since your code works.&amp;nbsp; But I have one more question, If the entity I want to select is nested in the block reference of another block reference (the block reference depth is two), then your program will prompt that "the entity your selected is not a line". So is there a way to select a line nested in two or more block references?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you try it ?&lt;/P&gt;
&lt;P&gt;result.ObjectId should return the ObjectId of the line and result.GetContainers() should return an array of two containers.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 08:32:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143292#M20857</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-11-13T08:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143340#M20858</link>
      <description>&lt;P&gt;Yes, I have already tried it. When I move the cursor over a line (then I l clicked )nested in a block reference which is nested in another block reference. The editor says "the&amp;nbsp; entity you selected is not a line"&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:04:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143340#M20858</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-13T09:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143361#M20859</link>
      <description>&lt;P&gt;I am sorry, I just find that What I selected is another entity(wipeout)&amp;nbsp; which I created to combine with the original block reference. I will move the wipeout under the original blocke reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I am working on a project in which user can select the edges of a block reference, then the addin can create (by the coordinates of the edges)and combine a wipeout with the block reference to make the block reference move over other entites.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:13:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143361#M20859</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-13T09:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143392#M20860</link>
      <description>&lt;P&gt;I find that the original block reference is moved to anther place and the wipeout I create is placed on the original place. I think it is the coordinates conversion problem. GetNestedEntity works as you say&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:27:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9143392#M20860</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-13T09:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to select certain objects in a block reference in model space using c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9145496#M20861</link>
      <description>&lt;P&gt;I find out why the original block reference is moved to another position:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;line.TransformBy(xform);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; line.StartPoint.TransformBy(xform);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; line.EndPoint.TransformBy(xform);&lt;/P&gt;&lt;P&gt;After I replace the code, it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;A wipeout is created and moved under the orginal block reference (the original block reference overlaps the wipeout and they are in a new block reference).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I run my code again, I use GetNestedEntity to select the edges of the new block reference, the objectId is the wipeout, maybe this time GetNestedEntity can not get the upper line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your code. It helps me a lot&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 03:53:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-select-certain-objects-in-a-block-reference-in-model/m-p/9145496#M20861</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-14T03:53:52Z</dc:date>
    </item>
  </channel>
</rss>

