<?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: Drawable Overrule not plotting through viewport. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6411903#M36936</link>
    <description>&lt;P&gt;I'm currently having the same problem (in AutoCAD Map 2013) with overruled entities not plotting correctly in viewports.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Were you able to resolve this issue?&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2016 02:07:15 GMT</pubDate>
    <dc:creator>jdowthwaite</dc:creator>
    <dc:date>2016-06-30T02:07:15Z</dc:date>
    <item>
      <title>Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6067277#M36934</link>
      <description>&lt;P&gt;I have created a DrawableOverrule which will draw a polyline as a table. &amp;nbsp;This draws and plots fine from model space. &amp;nbsp;When I view it through a paperspace viewport, it still looks good, but when I plot, it doesn't show up at all. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested this on both 2015 and 2016 versions of Civil 3d. &amp;nbsp;Can anybody help with what I am missing? &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have even tried changing my overrule to as simple as drawing a circle and even that&amp;nbsp;will not plot through a paperspace viewport. &amp;nbsp;Here is the&amp;nbsp;simple example which will not plot but shows up fine on the screen and also plots fine from model space (it draws a circle instead of the polyline):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            var polyline = drawable as Autodesk.AutoCAD.DatabaseServices.Polyline;
            if (polyline != null &amp;amp;&amp;amp; polyline.ObjectId.IsValid)
            {
                var labelTable = polyline.ReadClassFromEntity&amp;lt;LabelTable&amp;gt;();
                if (labelTable == null) return base.WorldDraw(drawable, wd);

                wd.Geometry.Circle(labelTable.TableInsertionPoint.ToPoint3d(), 5, Vector3d.ZAxis);
                return true;
            }
            return base.WorldDraw(drawable, wd);
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it helps, here is my overrule code. &amp;nbsp;It may not make sense out of context, but at least you can see what I'm doing and how I'm drawing the entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            var polyline = drawable as Autodesk.AutoCAD.DatabaseServices.Polyline;
            if(polyline!=null &amp;amp;&amp;amp; polyline.ObjectId.IsValid)
            {
                var labelTable = polyline.ReadClassFromEntity&amp;lt;LabelTable&amp;gt;();
                if (labelTable == null) return base.WorldDraw(drawable, wd);

               
                ILabelTableSettings settings =
                    LabelTableSettings.GetLabelTableSettings(polyline.Database, true);
                
                if (settings == null) return base.WorldDraw(drawable, wd);

                // get intersections that are inside of our polyline
                var pipesPlugin = PlugInManager.GetPlugIn&amp;lt;PipesPlugIn&amp;gt;();
                if(pipesPlugin!=null)
                {
                    string annotationLayer = "0";
                    ObjectId annotationLayerId = ObjectId.Null;
                    string tableLayer = "0";
                    // GetPipeCrossings will consider whether or not a Viewport is part of the labeltable.
                    // GetPipeCrossings will convert intersection points?

                    var crossings = labelTable.GetPipeCrossings(polyline);
                    crossings.Sort((crossing, pipeCrossing) =&amp;gt; crossing.IntersectionPoint.X.CompareTo(pipeCrossing.IntersectionPoint.X));

                    // get xdata values, table insertion point, text height
                    using (var tr = polyline.Database.TransactionManager.StartTransaction())
                    {
                        var layers = polyline.Database.LayerTableId.GetObject(OpenMode.ForRead) as LayerTable;
                        if(layers!=null)
                            foreach (var layer in layers)
                            {
                                var layerObj = layer.GetObject(OpenMode.ForRead) as LayerTableRecord;
                                if (layerObj!=null &amp;amp;&amp;amp; layerObj.Name.EndsWith(settings.AnnotationLayer))
                                {
                                    annotationLayer = layerObj.Name;
                                    annotationLayerId = layer;
                                }
                                if (layerObj != null &amp;amp;&amp;amp; layerObj.Name.EndsWith(settings.TableLayer))
                                {
                                    tableLayer = layerObj.Name;
                                }
                            }
                    }
                    var acadTable = new Table();
                    acadTable.SetDatabaseDefaults();
                    acadTable.Layer = tableLayer;
                    acadTable.Position = labelTable.TableInsertionPoint.ToPoint3d();
                    var mtext = new MText();
                    mtext.SetDatabaseDefaults();
                    mtext.Height = labelTable.TextHeight;
                    var columns = settings.Columns.ToList();
                    if (crossings.Count &amp;gt; 0)
                    {
                        acadTable.InsertColumns(0, mtext.Height * 12, columns.Count);
                        Enumerable.Range(0, columns.Count )
                            .ForEach(
                                x =&amp;gt;
                                {
                                    // get the column from the label table, we read the width and that is all.
                                    var myColumn =
                                        labelTable.Columns.FirstOrDefault(y =&amp;gt; y.GetType() == columns[x].GetType());
                                    // if it doesn't exist, we just put it in there...it's the same reference, but no
                                    // worries, once we serialize and then deserialize, i think it will be unique.
                                    if (myColumn == null)
                                    {
                                        myColumn = columns[x];
                                        labelTable.Columns.Add(myColumn);
                                    }
                                    acadTable.Columns[x].Width = myColumn.WidthFactor*mtext.Height;
                                });

                        acadTable.InsertRows(0, mtext.Height * settings.RowHeightMultiplier, crossings.Count);

                        // sets up the first row
                        Enumerable.Range(0, columns.Count).ForEach(x =&amp;gt;
                        {
                            acadTable.Cells[0, x].TextHeight = mtext.Height*1.2;
                            acadTable.Cells[0, x].TextString = columns[x].Header;
                            acadTable.Rows[0].Height = mtext.Height*1.2*settings.RowHeightMultiplier;
                        });

                        int row = 1;
                        int crossingLabel = labelTable.StartIndex;
                        var doc = CivilApplication.ActiveDocument;
                        foreach (var crossing in crossings)
                        {
                            // todo: find the crossing by number
                            // crossing index is always first since we set it to Canreorder = false
                            acadTable.Cells[row, 0].TextHeight = mtext.Height;
                            acadTable.Cells[row, 0].TextString = crossingLabel.ToString();
                            acadTable.Rows[row].Height = mtext.Height*settings.RowHeightMultiplier;

                            for (int i = 1; i &amp;lt; columns.Count; i++)
                            {
                                acadTable.Cells[row, i].TextHeight = mtext.Height;
                                acadTable.Cells[row, i].TextString = columns[i].GetText(crossing);
                            }

                            row++;

                            // do we have an annotation point for this crossing?  it will fetch the default if one doesn't exist.
                            var annoPoints = labelTable.GetIntersectionAndAnnotationPoint(crossing.CrossingId);

                            // draw the label on the crossing
                            var leader = new Leader();
                            leader.SetDatabaseDefaults();
                            leader.Layer = annotationLayer;
                            leader.AppendVertex(annoPoints.Item1.ToPoint3d());
                            leader.AppendVertex(annoPoints.Item2.ToPoint3d());
                            leader.Dimasz = labelTable.TextHeight;
                            leader.Dimscale = 1;
                            leader.WorldDraw(wd);

                            // draw Hex and Text
                            // need text size on LabelTable
                            var hatch = new Hatch();
                            hatch.SetDatabaseDefaults();
                            hatch.Layer = annotationLayer;
                            hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
                            //hatch.ColorIndex = 1;
                            var loop = new Polyline();
                            loop.SetDatabaseDefaults();
                            loop.Layer = annotationLayer;
                            var vector = new Vector2d(labelTable.TextHeight * 1.1, 0);
                            var annoPoint = annoPoints.Item2;
                            loop.AddVertexAt(0, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2*Math.PI/6);
                            loop.AddVertexAt(1, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2 * Math.PI / 6);
                            loop.AddVertexAt(2, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2 * Math.PI / 6);
                            loop.AddVertexAt(3, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2 * Math.PI / 6);
                            loop.AddVertexAt(4, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2 * Math.PI / 6);
                            loop.AddVertexAt(5, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            vector = vector.RotateBy(2 * Math.PI / 6);
                            loop.AddVertexAt(6, annoPoint.ToPoint2d().Add(vector), 0, 0, 0);
                            loop.Closed = true;
                            var points = new Point2dCollection();
                            for (int i = 0; i &amp;lt; loop.NumberOfVertices; i++)
                            {
                                points.Add(loop.GetPoint2dAt(i));
                            }
                            hatch.AppendLoop(HatchLoopTypes.Default, points, new DoubleCollection());
                            hatch.EvaluateHatch(false);
                            var color = wd.SubEntityTraits.Color;
                            wd.SubEntityTraits.Color = 247;
                            hatch.WorldDraw(wd);
                            wd.SubEntityTraits.Color = color;
                            wd.Geometry.Polyline(loop, 0, loop.NumberOfVertices);
                            var text = new DBText();
                            text.SetDatabaseDefaults();
                            text.Layer = annotationLayer;
                            text.Height = labelTable.TextHeight;
                            text.TextString = crossingLabel.ToString();
                            text.Position = annoPoint.ToPoint3d();
                            text.HorizontalMode = TextHorizontalMode.TextAlign;
                            text.Justify = AttachmentPoint.MiddleCenter;
                            text.AlignmentPoint = annoPoint.ToPoint3d();
                            text.AdjustAlignment(polyline.Database);
                            text.WorldDraw(wd);

                            // increment the label last
                            crossingLabel++;

                        }
                        acadTable.DeleteColumns(acadTable.Columns.Count-1, 1);
                        acadTable.InsertRows(0, mtext.Height*1.5, 1);
                        acadTable.MergeCells(CellRange.Create(acadTable, 0, 0, 0, columns.Count - 1));
                        acadTable.Cells[0, 0].TextString = "UTILITY CROSSINGS";
                        acadTable.Cells[0, 0].TextHeight = mtext.Height*1.4;
                        acadTable.Rows[0].Height = mtext.Height*1.4*settings.RowHeightMultiplier;
                        CellRange.Create(acadTable,0,0,acadTable.Rows.Count-1, acadTable.Columns.Count-1).Alignment = CellAlignment.MiddleCenter;
                        acadTable.WorldDraw(wd);
                        return true;
                    }
                }
            }
            return base.WorldDraw(drawable, wd);
        }&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Mar 2016 03:17:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6067277#M36934</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-03T03:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6204233#M36935</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide buildable sample? Below code for circle is working fine (printing fine from paper space)&lt;/P&gt;
&lt;PRE&gt;public class MyTestCommands
{
    private static circleOverrule _overruleCirle = null;
    [CommandMethod("circleOverrule")]
    public void circleOverrule()
    {
        if (_overruleCirle == null)
        {
            _overruleCirle = new circleOverrule();
            Overrule.AddOverrule(RXClass.GetClass(typeof(Circle)), _overruleCirle, false);
        }
        else
        {
            Overrule.RemoveOverrule(RXClass.GetClass(typeof(Circle)), _overruleCirle);
            _overruleCirle = null;
        }

        Application.DocumentManager.MdiActiveDocument.Editor.Regen();
    }
}

public class circleOverrule : Autodesk.AutoCAD.GraphicsInterface.DrawableOverrule
{
    public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd)
    {
        var circle = drawable as Circle;

        wd.Geometry.Circle(circle.Center, circle.Radius * 0.5, Vector3d.ZAxis);

        return base.WorldDraw(drawable, wd);
    }
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Mar 2016 10:12:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6204233#M36935</guid>
      <dc:creator>Virupaksha_aithal</dc:creator>
      <dc:date>2016-03-08T10:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6411903#M36936</link>
      <description>&lt;P&gt;I'm currently having the same problem (in AutoCAD Map 2013) with overruled entities not plotting correctly in viewports.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Were you able to resolve this issue?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 02:07:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6411903#M36936</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2016-06-30T02:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6425065#M36937</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you plotting in background? if yes, please try with plotting in Foreground (set BACKGROUNDPLOT = 0)&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 06:20:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6425065#M36937</guid>
      <dc:creator>Virupaksha_aithal</dc:creator>
      <dc:date>2016-07-08T06:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6425813#M36938</link>
      <description>We currently have BACKGROUNDPLOT set to 0. I've tested it with 0 and 1, neither makes a difference. The overrule entity is still not showing in the plot preview window or plotted file.&lt;BR /&gt;&lt;BR /&gt;Was there a solution found for the case I reference in my original post?</description>
      <pubDate>Fri, 08 Jul 2016 15:04:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6425813#M36938</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2016-07-08T15:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6430763#M36939</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please test the attached sample project at your end? Refer the screen cast of the working in AutoCAD 2013 at my end &lt;A href="http://autode.sk/29sR5oz" target="_blank"&gt;http://autode.sk/29sR5oz&lt;/A&gt; .&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 07:24:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/6430763#M36939</guid>
      <dc:creator>Virupaksha_aithal</dc:creator>
      <dc:date>2016-07-12T07:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Drawable Overrule not plotting through viewport.</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/7288070#M36940</link>
      <description>&lt;P&gt;I was recently forced to revisit this issue and get it resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With help from the simple Circle overrule and getting it to work, I started troubleshooting my code and realized that the problem was caused by an uncomitted transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My overrule worked perfectly in model, plotted in model, showed up through a viewport and everything, so I never thought there was a problem. But in order to know how to draw my table, I have to read information from the object and even though it was a READOnly transaction, I needed to commit() it to fix my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now it works as designed. It was a one-liner.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So apparently it's a good idea to always close your transactions. Lesson learned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 16:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawable-overrule-not-plotting-through-viewport/m-p/7288070#M36940</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-09T16:47:08Z</dc:date>
    </item>
  </channel>
</rss>

