<?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: Problem with Inserting a Tag/Multi-View Block Reference in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12565512#M5427</link>
    <description>&lt;P&gt;So, I ended up figuring out a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the program runs, I have to change the multi-view block's definition in the properties palette, and then change it back to the original definition. This seems to "refresh" the multi view block in some way and makes the grips available. However, when selected, its not defined as a Tag, but still functions as one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd prefer it to be recognized as a tag, but as long as the behavior is what I need, I won't complain. Any fixes or suggestions still welcome.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 21:11:20 GMT</pubDate>
    <dc:creator>michaeleGFMZG</dc:creator>
    <dc:date>2024-02-16T21:11:20Z</dc:date>
    <item>
      <title>Problem with Inserting a Tag/Multi-View Block Reference</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12565131#M5426</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I wrote some code to insert a TAG into a drawing for each MEP Wire that is found in model space. The code works fine except for one problem: The tag is inserted as a Multi View Block Reference instead of a Tag. Tags are created from multi-view block definitions but I can't seem to figure out where I'm going wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've provided pictures of the native Tag (Created using the native AutoCAD Tag creation tool) and my custom tag created from the vb.net code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both have the same information in the properties palette, but AutoCAD reads my custom tag as a "multi view block" rather than as a tag like the native tag. You can see this in the top of the ribbon with the additional options available for a native Tag. Additionally, my custom tag has no grips nor the option to edit the attributes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code uses the native tag's definition to create a new multiview block reference which attaches to all the Wires in blue. I'll include my code below. Thanks for anyone that can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;Dim doc As Document = application.DocumentManager.MdiActiveDocument&lt;BR /&gt;Dim docdb As Database = doc.Database&lt;BR /&gt;Dim ED As Editor = doc.Editor&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;CommandMethod("AddTag2Wire")&amp;gt;&lt;BR /&gt;Public Sub AddTag2Wire()&lt;/P&gt;&lt;P&gt;Dim PEO As New PromptEntityOptions(vbNewLine + "Select The Tag To Replicate")&lt;/P&gt;&lt;P&gt;Dim Prompt = ED.GetEntity(PEO)&lt;BR /&gt;Dim TagObjectId = Prompt.ObjectId&lt;/P&gt;&lt;P&gt;If Prompt.Status = PromptStatus.Cancel Then&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim PEO2 As New PromptIntegerOptions(vbNewLine + "Input Text Height (4, 6 or 8)")&lt;/P&gt;&lt;P&gt;Dim PromptintegerResult = ED.GetInteger(PEO2)&lt;/P&gt;&lt;P&gt;If PromptIntegerResult.Status = PromptStatus.Cancel Then&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim PIR = PromptintegerResult.Value&lt;/P&gt;&lt;P&gt;Using trans As Transaction = docdb.TransactionManager.StartTransaction&lt;/P&gt;&lt;P&gt;Dim BLOCKTABLE As BlockTable = trans.GetObject(docdb.BlockTableId, OpenMode.ForRead)&lt;BR /&gt;Dim MODELSPACE As BlockTableRecord = trans.GetObject(BLOCKTABLE(BlockTableRecord.ModelSpace), OpenMode.ForWrite) 'OPENS MODEL SPACE&lt;BR /&gt;Dim OpenTag As MultiViewBlockReference = trans.GetObject(TagObjectId, OpenMode.ForRead)&lt;BR /&gt;Dim OpenTagDefinitionId = OpenTag.BlockDefId&lt;/P&gt;&lt;P&gt;For Each ObjectId As objectid In MODELSPACE&lt;BR /&gt;If ObjectId.ObjectClass.Name = "AecbDbWire" Then&lt;BR /&gt;Dim OpenWire As Wire = trans.GetObject(ObjectId, OpenMode.ForRead)&lt;BR /&gt;Dim Location = OpenWire.Location&lt;BR /&gt;Dim InsertLocation As New Point3d(Location.X, Location.Y, 0)&lt;/P&gt;&lt;P&gt;Dim NewTag As New MultiViewBlockReference&lt;BR /&gt;NewTag.BlockDefId = OpenTagDefinitionId&lt;/P&gt;&lt;P&gt;If PIR = 4 Then&lt;BR /&gt;Dim TagScale As New Scale3d(4, 4, 1)&lt;BR /&gt;NewTag.Scale = TagScale&lt;BR /&gt;ElseIf PIR = 6 Then&lt;BR /&gt;Dim TagScale As New Scale3d(6, 6, 1)&lt;BR /&gt;NewTag.Scale = TagScale&lt;BR /&gt;ElseIf PIR = 8 Then&lt;BR /&gt;Dim TagScale As New Scale3d(8, 8, 1)&lt;BR /&gt;NewTag.Scale = TagScale&lt;BR /&gt;Else&lt;BR /&gt;ED.WriteMessage(vbNewLine + "Only 4, 6 or 8 Are Acceptable Arguments")&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;MODELSPACE.AppendEntity(NewTag)&lt;BR /&gt;trans.AddNewlyCreatedDBObject(NewTag, True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim TagAnchor As New AnchorExtendedTagToEntity&lt;BR /&gt;TagAnchor.SubSetDatabaseDefaults(docdb)&lt;BR /&gt;TagAnchor.SetToStandard(docdb)&lt;BR /&gt;TagAnchor.ForceHorizontal = True&lt;BR /&gt;TagAnchor.ReferencedEntityId = ObjectId&lt;BR /&gt;NewTag.SetAnchor(TagAnchor)&lt;BR /&gt;NewTag.Location = New Point3d(0, 0, 0)&lt;/P&gt;&lt;P&gt;Else Continue For&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;trans.Commit()&lt;BR /&gt;End Using&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 17:50:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12565131#M5426</guid>
      <dc:creator>michaeleGFMZG</dc:creator>
      <dc:date>2024-02-16T17:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Inserting a Tag/Multi-View Block Reference</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12565512#M5427</link>
      <description>&lt;P&gt;So, I ended up figuring out a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the program runs, I have to change the multi-view block's definition in the properties palette, and then change it back to the original definition. This seems to "refresh" the multi view block in some way and makes the grips available. However, when selected, its not defined as a Tag, but still functions as one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd prefer it to be recognized as a tag, but as long as the behavior is what I need, I won't complain. Any fixes or suggestions still welcome.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 21:11:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12565512#M5427</guid>
      <dc:creator>michaeleGFMZG</dc:creator>
      <dc:date>2024-02-16T21:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Inserting a Tag/Multi-View Block Reference</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12569637#M5428</link>
      <description>&lt;P&gt;For the "Tag" menu to appear when the MultiViewBlockReference Tag is selected, the information must be attached via XData.&lt;BR /&gt;An easy way to do this is to copy the XData data from the MultiviewBlockReference Tag used.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  newTag.XData = OpenTag.XData&lt;/LI-CODE&gt;&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("AddTag2Wire", CommandFlags.Modal)]
        public void AddTag2Wire()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;           

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect MultiviewBlockreference tag To Replicate ");
            peo.SetRejectMessage("\nNot a MultiViewBlockReference tag.");
            peo.AddAllowedClass(typeof(MultiViewBlockReference), false);
            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\nSelection error - aborting");
                return;
            }
            
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord ms = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                MultiViewBlockReference OpenTag = trans.GetObject(per.ObjectId, OpenMode.ForRead) as MultiViewBlockReference;
                AcDb.ObjectId OpenTagDefinitionId = OpenTag.BlockDefId;

                foreach (AcDb.ObjectId objectId in ms)
                {
                    if ((objectId.ObjectClass.Name == "AecbDbWire"))
                    {
                        Wire OpenWire = trans.GetObject(objectId, OpenMode.ForRead) as Wire;
                        Point3d location = OpenWire.Location;
                        Point3d InsertLocation = new Point3d(location.X, location.Y, 0);
                        MultiViewBlockReference newTag = new MultiViewBlockReference();
                        newTag.BlockDefId = OpenTagDefinitionId;
                        newTag.Scale = OpenTag.Scale;
                        newTag.Layer = OpenTag.Layer;
                        newTag.XData = OpenTag.XData;

                        ms.AppendEntity(newTag);
                        trans.AddNewlyCreatedDBObject(newTag, true);
                        AnchorExtendedTagToEntity tagAnchor = new AnchorExtendedTagToEntity();
                        tagAnchor.SubSetDatabaseDefaults(db);
                        tagAnchor.SetToStandard(db);
                        tagAnchor.ForceHorizontal = true;
                        tagAnchor.ReferencedEntityId = objectId;
                        tagAnchor.AllowIndependentUpdate = true;
                        newTag.SetAnchor(tagAnchor);
                        newTag.Location = location;
                    }            
                }
                trans.Commit();
            }
        }         
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gphanauer_0-1708365800722.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1327857iAC5BA8699A27B110/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gphanauer_0-1708365800722.png" alt="gphanauer_0-1708365800722.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gphanauer_1-1708365862781.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1327859iC26B0DB351A0F384/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gphanauer_1-1708365862781.png" alt="gphanauer_1-1708365862781.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 18:06:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12569637#M5428</guid>
      <dc:creator>Gepaha</dc:creator>
      <dc:date>2024-02-19T18:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Inserting a Tag/Multi-View Block Reference</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12576195#M5429</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/565180"&gt;@Gepaha&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll work on updating this over the weekend. Seems quite easy to incorporate XData... I'll have to read into XData and how else it can be applied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like you're using AutoCAD MEP also! It's nice to see someone else using this vertical. I only have about 4 months experience customizing MEP, but if you want to exchange some ideas, feel free to message me directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 14:38:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-inserting-a-tag-multi-view-block-reference/m-p/12576195#M5429</guid>
      <dc:creator>michaeleGFMZG</dc:creator>
      <dc:date>2024-02-22T14:38:17Z</dc:date>
    </item>
  </channel>
</rss>

