.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[VB.net] How to show entity property or XData in docking palette

1 REPLY 1
Reply
Message 1 of 2
alistairc
931 Views, 1 Reply

[VB.net] How to show entity property or XData in docking palette

Hi all,







I tried to creat a dockable palette to show object entity( maybe for xdata later)



Here is the code for palette










{color:#0000ff}Imports System.Runtime{color}







{color:#0000ff}Imports Autodesk.AutoCAD.Runtime{color}







{color:#0000ff}Imports Autodesk.AutoCAD.ApplicationServices{color}







{color:#0000ff}Imports AcApp = Autodesk.AutoCAD.ApplicationServices.Application{color}







{color:#0000ff}Imports Autodesk.AutoCAD.DatabaseServices{color}







{color:#0000ff}Imports Autodesk.AutoCAD.EditorInput{color}







{color:#0000ff}Public Class command{color}







{color:#0000ff}Implements Autodesk.AutoCAD.Runtime.IExtensionApplication{color}







{color:#0000ff}Friend Shared m_ps As Autodesk.AutoCAD.Windows.PaletteSet = Nothing{color}







{color:#0000ff}Dim objDoc As Autodesk.AutoCAD.ApplicationServices.Document{color}







{color:#0000ff}Dim mypalette As Container{color}







{color:#0000ff}Public Event PointMonitorEventHandler(ByVal ShowInfo){color}







{color:#0000ff}' Define command{color}







{color:#0000ff}<CommandMethod("Quickview")> _{color}







{color:#0000ff}Public Sub DoIt(){color}







{color:#0000ff}If m_ps Is Nothing Then{color}







{color:#0000ff}m_ps = New Autodesk.AutoCAD.Windows.PaletteSet("Quick View", _{color}







{color:#0000ff}New Guid("{ECBFEC73-9FE4-4aa2-8E4B-3068E94A2BFA}")){color}







{color:#0000ff}' m_ps = New Autodesk.AutoCAD.Windows.PaletteSet("Quick View"){color}







{color:#0000ff}Dim myPalette As Container = New Container() {color}{color:#008000}'---This is my palette class{color}







{color:#0000ff}m_ps.Add("Quick View", myPalette){color}











{color:#0000ff}m_ps.Visible = True{color}







{color:#0000ff}AddHandler Application.DocumentManager.MdiActiveDocument.Editor.PointMonitor, New Autodesk.AutoCAD.EditorInput.PointMonitorEventHandler(AddressOf ShowInfo){color}




{color:#0000ff}End Sub







{color}{color:#000000}To handle PointMonitor I use the following event







{color}{color:#000000}




{color:#003366}Private Sub ShowInfo(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.EditorInput.PointMonitorEventArgs){color}







{color:#003366}Dim ePaths() As FullSubentityPath = e.Context.GetPickedEntities(){color}







{color:#003366}If ePaths.Length > 0 Then{color}







{color:#003366}Dim ePath As FullSubentityPath = ePaths(0){color}







{color:#003366}Dim db As Database = HostApplicationServices.WorkingDatabase{color}







{color:#003366}Dim t As Transaction = db.TransactionManager.StartTransaction(){color}







{color:#003366}Try{color}







{color:#003366}Dim ent As Entity = CType(t.GetObject(ePath.GetObjectIds()(0), OpenMode.ForRead), Entity){color}







{color:#003366}mypalette.txtObject.Text = ent.GetType().ToString() {color}{color:#008000}'--this will give a fatal error{color}







{color:#003366}e.AppendToolTipText("I am an " + ent.GetType().ToString()) {color}{color:#008000}'--For tooltip it works fine{color}







{color:#003366}Finally{color}







{color:#003366}t.Dispose(){color}







{color:#003366}End Try{color}







{color:#003366}End If{color}







{color:#003366}End Sub







{color}{color:#000000}anybody give me some adivce?







thanks a lot{color}




{color}
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: alistairc


Please post in Rich Text format or attached code in
a text file.

 

Joe ...


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
Hi
all,







I tried to creat a dockable palette to
show object entity( maybe for xdata later)



Here is the code
for palette











{color:#0000ff}Imports
System.Runtime{color}








{color:#0000ff}Imports
Autodesk.AutoCAD.Runtime{color}








{color:#0000ff}Imports
Autodesk.AutoCAD.ApplicationServices{color}








{color:#0000ff}Imports AcApp =
Autodesk.AutoCAD.ApplicationServices.Application{color}








{color:#0000ff}Imports
Autodesk.AutoCAD.DatabaseServices{color}








{color:#0000ff}Imports
Autodesk.AutoCAD.EditorInput{color}








{color:#0000ff}Public Class command{color}








{color:#0000ff}Implements
Autodesk.AutoCAD.Runtime.IExtensionApplication{color}








{color:#0000ff}Friend Shared m_ps As
Autodesk.AutoCAD.Windows.PaletteSet = Nothing{color}








{color:#0000ff}Dim objDoc As
Autodesk.AutoCAD.ApplicationServices.Document{color}








{color:#0000ff}Dim mypalette As
Container{color}








{color:#0000ff}Public Event PointMonitorEventHandler(ByVal
ShowInfo){color}








{color:#0000ff}' Define command{color}








{color:#0000ff}<CommandMethod("Quickview")>
_{color}








{color:#0000ff}Public Sub DoIt(){color}








{color:#0000ff}If m_ps Is Nothing
Then{color}








{color:#0000ff}m_ps = New
Autodesk.AutoCAD.Windows.PaletteSet("Quick View", _{color}








{color:#0000ff}New
Guid("{ECBFEC73-9FE4-4aa2-8E4B-3068E94A2BFA}")){color}








{color:#0000ff}' m_ps = New
Autodesk.AutoCAD.Windows.PaletteSet("Quick View"){color}








{color:#0000ff}Dim myPalette As Container = New Container()
{color}{color:#008000}'---This is my palette class{color}








{color:#0000ff}m_ps.Add("Quick View",
myPalette){color}












{color:#0000ff}m_ps.Visible = True{color}








{color:#0000ff}AddHandler
Application.DocumentManager.MdiActiveDocument.Editor.PointMonitor, New
Autodesk.AutoCAD.EditorInput.PointMonitorEventHandler(AddressOf
ShowInfo){color}




{color:#0000ff}End
Sub







{color}{color:#000000}To handle
PointMonitor I use the following
event







{color}{color:#000000}





{color:#003366}Private Sub ShowInfo(ByVal sender As Object,
ByVal e As
Autodesk.AutoCAD.EditorInput.PointMonitorEventArgs){color}








{color:#003366}Dim ePaths() As FullSubentityPath =
e.Context.GetPickedEntities(){color}








{color:#003366}If ePaths.Length > 0
Then{color}








{color:#003366}Dim ePath As FullSubentityPath =
ePaths(0){color}








{color:#003366}Dim db As Database =
HostApplicationServices.WorkingDatabase{color}








{color:#003366}Dim t As Transaction =
db.TransactionManager.StartTransaction(){color}








{color:#003366}Try{color}








{color:#003366}Dim ent As Entity =
CType(t.GetObject(ePath.GetObjectIds()(0), OpenMode.ForRead),
Entity){color}








{color:#003366}mypalette.txtObject.Text =
ent.GetType().ToString() {color}{color:#008000}'--this will give a fatal
error{color}








{color:#003366}e.AppendToolTipText("I am an " +
ent.GetType().ToString()) {color}{color:#008000}'--For tooltip it works
fine{color}








{color:#003366}Finally{color}








{color:#003366}t.Dispose(){color}








{color:#003366}End Try{color}








{color:#003366}End If{color}








{color:#003366}End
Sub







{color}{color:#000000}anybody give me some
adivce?







thanks a
lot{color}




{color}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost