<?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 Filleting Polylines: &amp;quot;The object is not in current space.&amp;quot; in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11384582#M11875</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to automate the filleting of all PolyLines in a drawing. I am doing so like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static ObjectIdCollection GetPolylineEntities(string layerName = null)
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var ed = doc.Editor;
    TypedValue[] filter;

    if (!String.IsNullOrEmpty(layerName))
    {
        filter = new TypedValue[]{
                            new TypedValue((int)DxfCode.Operator,"&amp;lt;and"),
                            new TypedValue((int)DxfCode.LayerName,layerName),
                            new TypedValue((int)DxfCode.Start,"LWPolyline"),
                            new TypedValue((int)DxfCode.Operator,"and&amp;gt;")
        };
    }
    else
    {
        filter = new TypedValue[] { new TypedValue((int)DxfCode.Start, "LWPolyline") };
    }

    // Build a filter list so that only entities
    // on the specified layer are selected

    var selectionFilter = new SelectionFilter(filter);
    var promptStatusResult = ed.SelectAll(selectionFilter);

    if (promptStatusResult.Status == PromptStatus.OK)
        return
            new ObjectIdCollection(
            promptStatusResult.Value.GetObjectIds()
            );
    else
        return new ObjectIdCollection();
}

[CommandMethod("Test", "FilletAll", CommandFlags.Modal)]
public void FilletAll()
{
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    var plineIds = GetPolylineEntities();

    var radiusPrompt = new PromptDoubleOptions("\nWhat radius? ");
    var radiusResponse = ed.GetDouble(radiusPrompt);

    if (radiusResponse.Status != PromptStatus.OK)
    {
        ed.WriteMessage("You must supply a valid radius\n");
        return;
    }

    // Suppress Command Line noise.
    var noMutt = Application.GetSystemVariable("NOMUTT");
    Application.SetSystemVariable("NOMUTT", 1);

    ed.Command("FILLETRAD", 0.5);

    var db = Application.DocumentManager.MdiActiveDocument.Database;

    using (var pm = new ProgressMeter())
    using (var tr = db.TransactionManager.StartTransaction())
    {
        pm.Start("Filleting Polylines");
        pm.SetLimit(plineIds.Count);

        foreach (ObjectId id in plineIds)
        {
            ed.Command("_.FILLET", "_P", id);
            pm.MeterProgress();
            System.Windows.Forms.Application.DoEvents();
        }

        pm.Stop();
        System.Windows.Forms.Application.DoEvents();
    }

    Application.SetSystemVariable("NOMUTT", noMutt);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This almost works -- I am able to repeatedly (and manually) click a single polyline, and eventually it will fillet all polylines. The issues with this is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;This requires manual intervention -- I'm attempting to do this all automatically through the code&lt;/LI&gt;&lt;LI&gt;It provides a bunch of the following error: "The object is not in current space.", which is why I need to manually click on polylines until those polylines have been processed.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So may question is: Is it possible to filter out polylines that are not in the current space? Or, if not possible, is there a way to detect that AutoCAD is supplying this error and simply handling it in some way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Sat, 27 Aug 2022 06:59:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-27T06:59:15Z</dc:date>
    <item>
      <title>Filleting Polylines: "The object is not in current space."</title>
      <link>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11384582#M11875</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to automate the filleting of all PolyLines in a drawing. I am doing so like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static ObjectIdCollection GetPolylineEntities(string layerName = null)
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var ed = doc.Editor;
    TypedValue[] filter;

    if (!String.IsNullOrEmpty(layerName))
    {
        filter = new TypedValue[]{
                            new TypedValue((int)DxfCode.Operator,"&amp;lt;and"),
                            new TypedValue((int)DxfCode.LayerName,layerName),
                            new TypedValue((int)DxfCode.Start,"LWPolyline"),
                            new TypedValue((int)DxfCode.Operator,"and&amp;gt;")
        };
    }
    else
    {
        filter = new TypedValue[] { new TypedValue((int)DxfCode.Start, "LWPolyline") };
    }

    // Build a filter list so that only entities
    // on the specified layer are selected

    var selectionFilter = new SelectionFilter(filter);
    var promptStatusResult = ed.SelectAll(selectionFilter);

    if (promptStatusResult.Status == PromptStatus.OK)
        return
            new ObjectIdCollection(
            promptStatusResult.Value.GetObjectIds()
            );
    else
        return new ObjectIdCollection();
}

[CommandMethod("Test", "FilletAll", CommandFlags.Modal)]
public void FilletAll()
{
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    var plineIds = GetPolylineEntities();

    var radiusPrompt = new PromptDoubleOptions("\nWhat radius? ");
    var radiusResponse = ed.GetDouble(radiusPrompt);

    if (radiusResponse.Status != PromptStatus.OK)
    {
        ed.WriteMessage("You must supply a valid radius\n");
        return;
    }

    // Suppress Command Line noise.
    var noMutt = Application.GetSystemVariable("NOMUTT");
    Application.SetSystemVariable("NOMUTT", 1);

    ed.Command("FILLETRAD", 0.5);

    var db = Application.DocumentManager.MdiActiveDocument.Database;

    using (var pm = new ProgressMeter())
    using (var tr = db.TransactionManager.StartTransaction())
    {
        pm.Start("Filleting Polylines");
        pm.SetLimit(plineIds.Count);

        foreach (ObjectId id in plineIds)
        {
            ed.Command("_.FILLET", "_P", id);
            pm.MeterProgress();
            System.Windows.Forms.Application.DoEvents();
        }

        pm.Stop();
        System.Windows.Forms.Application.DoEvents();
    }

    Application.SetSystemVariable("NOMUTT", noMutt);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This almost works -- I am able to repeatedly (and manually) click a single polyline, and eventually it will fillet all polylines. The issues with this is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;This requires manual intervention -- I'm attempting to do this all automatically through the code&lt;/LI&gt;&lt;LI&gt;It provides a bunch of the following error: "The object is not in current space.", which is why I need to manually click on polylines until those polylines have been processed.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So may question is: Is it possible to filter out polylines that are not in the current space? Or, if not possible, is there a way to detect that AutoCAD is supplying this error and simply handling it in some way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2022 06:59:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11384582#M11875</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-27T06:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Filleting Polylines: "The object is not in current space."</title>
      <link>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11384875#M11876</link>
      <description>&lt;P&gt;Editor.SelectAll() would select all entities in all layouts/spaces unless you have filter, and the "Fillet" command seems only work with entities in current space. So, in your case, if you want to select plolylines in specific layout ("Model", or one of the layout), you need to add a "LayoutName" filter, say, modelspace:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new TypedVlue((int)DxfCode.LayoutName, "MODEL")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, if you just want current space, then you need to find out the current space's layout name, in order to set the filter TypedValue.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2022 12:44:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11384875#M11876</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-08-27T12:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Filleting Polylines: "The object is not in current space."</title>
      <link>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11396480#M11877</link>
      <description>&lt;P&gt;Thank you! The above helped me determine that my issue was related to this as well as some external references I was missing, which was where AutoCAD was failing.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 23:10:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/filleting-polylines-quot-the-object-is-not-in-current-space-quot/m-p/11396480#M11877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-01T23:10:45Z</dc:date>
    </item>
  </channel>
</rss>

