<?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: Tried to display block attributes when block is selected on palette in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242123#M36521</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan﻿&lt;/a&gt;&amp;nbsp;First of all thanks for reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question is I want to display block attributes on palette whenever user selects block, I added ed.selectionadded event for that.&lt;/P&gt;&lt;P&gt;everything is good but textbox does not show anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command you were talking about is for cancelling selection, I am new programmer , I will try to remove that from within transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pankaj&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2016 17:01:01 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-03-30T17:01:01Z</dc:date>
    <item>
      <title>Tried to display block attributes when block is selected on palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6241540#M36519</link>
      <description>&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;View: Xaml code&lt;/P&gt;&lt;PRE&gt;&amp;lt;UserControl x:Class="View_ATT"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:SchneiderMacros"
             mc:Ignorable="d" 
             d:DesignHeight="230" d:DesignWidth="325"&amp;gt;
    &amp;lt;Grid Background="#FF007ACC"&amp;gt;
        &amp;lt;StackPanel Margin="5 " Background="#FF252526" &amp;gt;
            &amp;lt;StackPanel Orientation="Horizontal" &amp;gt;
                &amp;lt;TextBlock x:Name="Block" Width=" 30" Margin=" 5" Text="Block " Foreground="#FFE6E6EE" FontWeight="Bold" TextDecorations="{x:Null}"/&amp;gt;
                &amp;lt;StackPanel &amp;gt;
                    &amp;lt;TextBlock x:Name="txtBlkName" Width=" 150" Margin=" 2" Foreground="#FFEAEAF3" Text="{Binding blkname,Mode=TwoWay,NotifyOnSourceUpdated=True}"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                    &amp;lt;TextBlock x:Name="txtblkBLKID" Width=" 150" Margin=" 2" Foreground="#FFDADAE4" Text="{Binding blockid,Mode=TwoWay,NotifyOnSourceUpdated=True}"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                &amp;lt;/StackPanel&amp;gt;
                &amp;lt;Button x:Name="GetAtt" Width="85" Margin=" 2" Content="Get Attributes"&amp;gt;&amp;lt;/Button&amp;gt;
                &amp;lt;Image Source="S:\Transfer\Pankaj_Potdar\acadplugin\unnamed.png" Height="28" Width="28" /&amp;gt;
            &amp;lt;/StackPanel&amp;gt;

            &amp;lt;StackPanel Orientation="Horizontal" Margin=" 5"&amp;gt;
                &amp;lt;StackPanel Margin=" 2" HorizontalAlignment="Left" Width="140"&amp;gt;
                    &amp;lt;TextBlock x:Name="tagDL" Margin="2 " Height=" 20" Text="{Binding tagDL,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2" &amp;gt;&amp;lt;/TextBlock&amp;gt;
                    &amp;lt;TextBlock x:Name="tagDN" Margin=" 2" Height=" 20" Text="{Binding tagDN,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                    &amp;lt;TextBlock x:Name="tagSQDPN" Margin=" 2" Height=" 20" Text="{Binding tagsqdpn,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                    &amp;lt;TextBlock x:Name="tagMODEL" Margin=" 2" Height=" 20" Text="{Binding tagmodel,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                    &amp;lt;TextBlock x:Name="tagMANUFACTURER" Margin=" 2" Height=" 20" Text="{Binding tagmanufacturer,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"&amp;gt;&amp;lt;/TextBlock&amp;gt;
                &amp;lt;/StackPanel&amp;gt;
                &amp;lt;StackPanel Margin=" 2" HorizontalAlignment="Right"  Width="140"&amp;gt;
                    &amp;lt;TextBox x:Name="txtboxDL" Margin="2 " Height=" 20" Text="{Binding devicelocation,Mode=TwoWay,NotifyOnSourceUpdated=True}"/&amp;gt;
                    &amp;lt;TextBox x:Name="txtboxDN" Margin="2 " Height=" 20" Text="{Binding devicename,Mode=TwoWay,NotifyOnSourceUpdated=True}"/&amp;gt;
                    &amp;lt;TextBox x:Name="txtboxSQDPN" Margin="2 " Height=" 20" Text="{Binding sqdpn,Mode=TwoWay,NotifyOnSourceUpdated=True}"/&amp;gt;
                    &amp;lt;TextBox x:Name="txtboxMODEL" Margin="2 " Height=" 20" Text="{Binding model,Mode=TwoWay,NotifyOnSourceUpdated=True}"/&amp;gt;
                    &amp;lt;TextBox x:Name="txtboxMANUFACTURER" Margin="2 " Height=" 20" Text="{Binding manufacturer,Mode=TwoWay,NotifyOnSourceUpdated=True}"/&amp;gt;

                &amp;lt;/StackPanel&amp;gt;
                &amp;lt;StackPanel Margin=" 0"&amp;gt;

                    &amp;lt;CheckBox x:Name="sqdpnhdn" Margin="0,55,0,0" HorizontalAlignment="Center" IsChecked="{Binding hidden, Mode=TwoWay, NotifyOnSourceUpdated=True}"/&amp;gt;
                &amp;lt;/StackPanel&amp;gt;
            &amp;lt;/StackPanel&amp;gt;
            &amp;lt;StackPanel Orientation="Horizontal" &amp;gt;
                &amp;lt;Button x:Name="btnUpdate" Width="50 " Height=" 25" Margin=" 10" HorizontalAlignment="Left" Content="Update "&amp;gt;&amp;lt;/Button&amp;gt;
                &amp;lt;Image Source="S:\Transfer\Pankaj_Potdar\acadplugin\Schneider-Electric_White.png" Height="45" Width="68" Margin=" 170,0,0,0" Stretch="Fill"/&amp;gt;
            &amp;lt;/StackPanel&amp;gt;
        &amp;lt;/StackPanel&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;&lt;/PRE&gt;&lt;P&gt;My Model&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Integration

Public Class GetATT_Model
    Public DL As String
    Public tagDL As String
    Public DN As String
    Public tagDN As String
    Public SQDPN As String
    Public tagSQDPN As String
    Public MODEL As String
    Public tagMODEL As String
    Public MANUFACTURER As String
    Public tagMANUFACTURER As String
    Public blkname As String
    Public blockID As String
    Public hiddden As Boolean

    Public Function findatt(objectid() As ObjectId)
        Dim device As New GetATT_Model

        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        If objectid.Length = 1 Then
            Using tr As Transaction = doc.TransactionManager.StartTransaction
                Dim cmd As String = "CANCELCOMMANDVBNET" &amp;amp; vbCr
                doc.SendStringToExecute(cmd, True, False, False)
                Dim blkref As BlockReference = tr.GetObject(objectid(0), OpenMode.ForRead)
                Dim ext As Extents3d
                Dim ent As Entity = tr.GetObject(objectid(0), OpenMode.ForRead)
                ext = ent.GeometricExtents
                device.blkname = blkref.Name
                device.blockID = blkref.ObjectId.ToString
                Dim attcol As Autodesk.AutoCAD.DatabaseServices.AttributeCollection = blkref.AttributeCollection
                For Each attid As ObjectId In attcol
                    Dim attref As AttributeReference = tr.GetObject(attid, OpenMode.ForRead)
                    Select Case attref.Tag.ToString
                        Case "DEVICE_LOCATION"
                            device.DL = attref.TextString.ToString
                            device.tagDL = attref.Tag.ToString
                        Case "DEVICE_NAME"
                            device.DN = attref.TextString.ToString
                            device.tagDN = attref.Tag.ToString
                        Case "SQD_PN"
                            device.SQDPN = attref.TextString.ToString
                            device.tagSQDPN = attref.Tag.ToString
                            If attref.Layer = "SQD_PN" Then
                                device.hiddden = False
                            Else
                                device.hiddden = True
                            End If
                        Case "MODEL"
                            device.MODEL = attref.TextString.ToString
                            device.tagMODEL = attref.Tag.ToString
                        Case "MANUFACTURER"
                            device.MANUFACTURER = attref.TextString.ToString
                            device.tagMANUFACTURER = attref.Tag.ToString

                    End Select
                Next
                ext.TransformBy(ed.CurrentUserCoordinateSystem.Inverse())

                zoomwin(ed, ext.MinPoint, ext.MaxPoint)
                tr.Commit()
            End Using
        Else
            MsgBox("Select only one block", MsgBoxStyle.Critical)
        End If

        Return device
    End Function

Public Sub zoomwin(ed As Editor, min As Point3d, max As Point3d)
        Dim min2d As Point2d = New Point2d(min.X, min.Y)
        Dim max2d As Point2d = New Point2d(max.X, max.Y)
        Dim view As ViewTableRecord = New ViewTableRecord
        view.CenterPoint = min2d + ((max2d - min2d) / 2)
        view.Height = max2d.Y - min2d.Y
        view.Width = max2d.X - min2d.X
        ed.SetCurrentView(view)

    End Sub

End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Xaml.vb code&lt;/P&gt;&lt;PRE&gt;Public Class View_ATT
    Public viewmodel As New GetATT_ViewModel
    Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        Me.DataContext = viewmodel

        ' Add any initialization after the InitializeComponent() call.

    End Sub

 Public Sub testit(sender As Object, e As SelectionAddedEventArgs)
     Dim objectid() As ObjectId = e.AddedObjects.GetObjectIds

     viewmodel.getattribute(objectid)


    End Sub

End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 13:35:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6241540#M36519</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-30T13:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Tried to display block attributes when block is selected on palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6241944#M36520</link>
      <description>&lt;P&gt;What purpose you post the code for? Any question?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing what issue you may have, one thing is immediately caught in my eyes: why do you call Document.SebdStringToExecute() to call a command "CANCELCOMMANDVBNET" during a Transaction. No matter what that command does, it is bad thing to call SendStringToExecute() during a Transaction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 15:51:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6241944#M36520</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2016-03-30T15:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Tried to display block attributes when block is selected on palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242123#M36521</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan﻿&lt;/a&gt;&amp;nbsp;First of all thanks for reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question is I want to display block attributes on palette whenever user selects block, I added ed.selectionadded event for that.&lt;/P&gt;&lt;P&gt;everything is good but textbox does not show anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command you were talking about is for cancelling selection, I am new programmer , I will try to remove that from within transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pankaj&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 17:01:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242123#M36521</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-30T17:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Tried to display block attributes when block is selected on palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242451#M36522</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To cancel a selection, you'd rather use the Editor.SetImpliedSelection() method passing it a null or empty ObjectId array.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 18:57:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242451#M36522</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-03-30T18:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Tried to display block attributes when block is selected on palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242472#M36523</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile﻿&lt;/a&gt;&amp;nbsp;thanks for reply it helped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am facing another problem now I added ed.selectionadded event handler but I am not able to remove it.&lt;/P&gt;&lt;P&gt;I posted below problem in different post but in case if yu can help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using below eventhandler to add e.selectionadded event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AddHandler ed.SelectionAdded, AddressOf testit&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I am using below statement to remove it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;RemoveHandler ed.SelectionAdded, AddressOf testit&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it does not get removed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My testit function,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public viewmodel As New GetATT_ViewModel
 Public Sub testit(sender As Object, e As SelectionAddedEventArgs)
        Dim objectid() As ObjectId = e.AddedObjects.GetObjectIds

        viewmodel.getattribute(objectid)


    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read somewhere that you need to make function shared but I can not make that as I am calling another function in it which is not shared.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 19:05:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/tried-to-display-block-attributes-when-block-is-selected-on/m-p/6242472#M36523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-30T19:05:46Z</dc:date>
    </item>
  </channel>
</rss>

