Xrecords (going from VBA to .NET)

Xrecords (going from VBA to .NET)

Anonymous
Not applicable
1,388 Views
19 Replies
Message 1 of 20

Xrecords (going from VBA to .NET)

Anonymous
Not applicable
Hello,

I have been spinning my wheels for near on 8 months now trying to figure
out how to create (and then read) Xrecords in .NET. Thus far i haven't
found any posts/lessons that have been of any help.

Below are the 2 VBA functions I use to create/read/delete my Xrecords in
AutoCAD. I hope someone can get me going in the right direction (this
little problem stands in my way of moving my applications to .NET).

Thank you to whoever decides to help me 😆

--------------------------------------
--------------------------------------
Create:::
Public Function vb_sxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo Create
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
Exit Function

Create:
If TrackingDictionary Is Nothing Then
Set TrackingDictionary =
ThisDrawing.Dictionaries.Add(TAG_DICTIONARY_NAME)
Set TrackingXRecord =
TrackingDictionary.AddXRecord(TAG_XRECORD_NAME)
End If
Resume
End Function

--------------------------------------
--------------------------------------
Read:::
Public Function vb_gxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
' Dim iCount As Long
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
DimSet = XRecordData(0)
Exit Function
NONE:
DimSet = ""
End Function

--------------------------------------
--------------------------------------
Delete:::
Public Function vb_rxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
TrackingDictionary.Delete
RemTRKFT
Exit Function
NONE:
End Function
0 Likes
1,389 Views
19 Replies
Replies (19)
Message 2 of 20

Anonymous
Not applicable
Did you try searching this newsgroup ?

I seem to recall quite a few posts on the topic, so
maybe a search on 'XRecord' might turn up something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5977788@discussion.autodesk.com...
Hello,

I have been spinning my wheels for near on 8 months now trying to figure
out how to create (and then read) Xrecords in .NET. Thus far i haven't
found any posts/lessons that have been of any help.

Below are the 2 VBA functions I use to create/read/delete my Xrecords in
AutoCAD. I hope someone can get me going in the right direction (this
little problem stands in my way of moving my applications to .NET).

Thank you to whoever decides to help me 😆

--------------------------------------
--------------------------------------
Create:::
Public Function vb_sxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo Create
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
Exit Function

Create:
If TrackingDictionary Is Nothing Then
Set TrackingDictionary =
ThisDrawing.Dictionaries.Add(TAG_DICTIONARY_NAME)
Set TrackingXRecord =
TrackingDictionary.AddXRecord(TAG_XRECORD_NAME)
End If
Resume
End Function

--------------------------------------
--------------------------------------
Read:::
Public Function vb_gxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
' Dim iCount As Long
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
DimSet = XRecordData(0)
Exit Function
NONE:
DimSet = ""
End Function

--------------------------------------
--------------------------------------
Delete:::
Public Function vb_rxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
TrackingDictionary.Delete
RemTRKFT
Exit Function
NONE:
End Function
0 Likes
Message 3 of 20

Anonymous
Not applicable
I've looked here a few times. they only seem to deal with xrecords on
objects...?

Tony Tanzillo wrote:
> Did you try searching this newsgroup ?
>
> I seem to recall quite a few posts on the topic, so
> maybe a search on 'XRecord' might turn up something.
>
0 Likes
Message 4 of 20

Anonymous
Not applicable
Try searching on 'NamedObjectsDictionaryId'.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5978249@discussion.autodesk.com...
I've looked here a few times. they only seem to deal with xrecords on
objects...?

Tony Tanzillo wrote:
> Did you try searching this newsgroup ?
>
> I seem to recall quite a few posts on the topic, so
> maybe a search on 'XRecord' might turn up something.
>
0 Likes
Message 5 of 20

Anonymous
Not applicable

ok, that gave me a few results (several that i had already looked at).



The only one that "seems" to be what I am after does not look like .NET
code?

---------------------

        Void(MakeXRecord())

        {



            Xrecord rec=new Xrecord();//Creates a Xrecord object



            rec.Data=new ResultBuffer(

                    new TypedValue((int)DxfCode.Text,

                                        "This is a test"),

                    new TypedValue((int)DxfCode.Int8,0),

                    new TypedValue((int)DxfCode.UcsOrg,

                                      new Point3d(0,0,0))

            );//Use the Data property of Xreord to



              //set the contents of the Xrecord object.



            Tools.AddDictionaryObject("test",rec,

                 Tools.Database.NamedObjectsDictionaryId);

            //Use the AddDictionaryObject() function to add the



            //Xrcord object to AutoCAD database.





            //list the entries we just added



            foreach (TypedValue rb in rec.Data)

            {

               Tools.Editor.WriteMessage(string.Format("TypedCode={0},

                                  Value={1}\n",rb.TypeCode,rb.Value));

            }

        }

-------------------------------



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

Try searching on 'NamedObjectsDictionaryId'.



0 Likes
Message 6 of 20

Anonymous
Not applicable
Seems to be working for me

Imports System
Imports System.Reflection
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Interop

Imports System.Windows.Forms.Form
'#
Public Class DictionaryUtils

_
Sub AddXDict()
Dim db As Database = HostApplicationServices.WorkingDatabase
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim nod As DBDictionary = trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite, False)
Dim dc As DBDictionary
Try
dc = trans.GetObject(nod.GetAt("TestDict"), OpenMode.ForWrite)
Catch
dc = New DBDictionary()
nod.SetAt("TestDict", dc)
trans.AddNewlyCreatedDBObject(dc, True)
End Try
Dim xr As Xrecord
Try
xr = trans.GetObject(dc.GetAt("XREC1"), OpenMode.ForWrite)
Catch
xr = New Xrecord()
xr.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "This a test XRecord"), _
New TypedValue(DxfCode.Angle, 3.14159), _
New TypedValue(DxfCode.Real, 1234.56789), _
New TypedValue(DxfCode.Int32, 1234), _
New TypedValue(DxfCode.Color, 1))

dc.SetAt("XREC1", xr)
trans.AddNewlyCreatedDBObject(xr, True)
End Try
trans.Commit()
End Using
End Sub


Public Shared Sub ReadXrecData(ByVal dictName As String, ByVal xrecName As String)

Dim db As Database = HostApplicationServices.WorkingDatabase
Using trans As Transaction = db.TransactionManager.StartTransaction()

Try
Dim nod As DBDictionary = CType(trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead), DBDictionary)
Dim dc As DBDictionary = CType(trans.GetObject(nod.GetAt(dictName), OpenMode.ForRead), DBDictionary)
Dim xr As Xrecord
xr = CType(trans.GetObject(dc.GetAt(xrecName), OpenMode.ForRead, False), Xrecord)
Dim rbuf As ResultBuffer = xr.Data
If rbuf Is Nothing Then
MsgBox(ControlChars.CrLf & "Xrecord does not have data attached.")
Else
Dim n As Integer = 0
Dim strRet As String = String.Empty
For Each itm As TypedValue In rbuf
strRet = strRet & String.Format(ControlChars.CrLf & "Item {0}" & ControlChars.Tab & "type: {1}" & ControlChars.Tab & "value: {2}", System.Math.Min(System.Threading.Interlocked.Increment(n), n - 1), itm.TypeCode, itm.Value)
Next
MsgBox(strRet)
rbuf.Dispose()
End If
trans.Commit()
Catch caught As System.Exception
MessageBox.Show(caught.StackTrace)
End Try
End Using

End Sub
...................
End Class
'#

~'J'~
0 Likes
Message 7 of 20

Anonymous
Not applicable
I can't tell you because your posts contain gibberish.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5978882@discussion.autodesk.com...
ok, that gave me a few results (several that i had already looked at).

The only one that "seems" to be what I am after does not look like .NET code?
---------------------
       Void(MakeXRecord())
       {

           Xrecord rec=new Xrecord();//Creates a Xrecord object

           rec.Data=new ResultBuffer(
                   new TypedValue((int)DxfCode.Text,
                                       "This is a test"),
                   new TypedValue((int)DxfCode.Int8,0),
                   new TypedValue((int)DxfCode.UcsOrg,
                                     new Point3d(0,0,0))
           );//Use the Data property of Xreord to

             //set the contents of the Xrecord object.

           Tools.AddDictionaryObject("test",rec,
                Tools.Database.NamedObjectsDictionaryId);
           //Use the AddDictionaryObject() function to add the

           //Xrcord object to AutoCAD database.


           //list the entries we just added

           foreach (TypedValue rb in rec.Data)
           {
              Tools.Editor.WriteMessage(string.Format("TypedCode={0},
                                 Value={1}\n",rb.TypeCode,rb.Value));
           }
       }
-------------------------------


Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
Try searching on 'NamedObjectsDictionaryId'.
0 Likes
Message 8 of 20

Anonymous
Not applicable
Forgot to say that this code was stealed from Lab4
Take a look at CreateDivision sub from there

~'J'~
0 Likes
Message 9 of 20

Anonymous
Not applicable
I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5978882@discussion.autodesk.com...
ok, that gave me a few results (several that i had already looked at).

The only one that "seems" to be what I am after does not look like .NET code?
---------------------
       Void(MakeXRecord())
       {

           Xrecord rec=new Xrecord();//Creates a Xrecord object

           rec.Data=new ResultBuffer(
                   new TypedValue((int)DxfCode.Text,
                                       "This is a test"),
                   new TypedValue((int)DxfCode.Int8,0),
                   new TypedValue((int)DxfCode.UcsOrg,
                                     new Point3d(0,0,0))
           );//Use the Data property of Xreord to

             //set the contents of the Xrecord object.

           Tools.AddDictionaryObject("test",rec,
                Tools.Database.NamedObjectsDictionaryId);
           //Use the AddDictionaryObject() function to add the

           //Xrcord object to AutoCAD database.


           //list the entries we just added

           foreach (TypedValue rb in rec.Data)
           {
              Tools.Editor.WriteMessage(string.Format("TypedCode={0},
                                 Value={1}\n",rb.TypeCode,rb.Value));
           }
       }
-------------------------------


Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
Try searching on 'NamedObjectsDictionaryId'.
0 Likes
Message 10 of 20

Anonymous
Not applicable
Sorry,
I have the big disorder in my files,
therefore I have recollected just after I have sent
my response to this thread

~'J'~
0 Likes
Message 11 of 20

Anonymous
Not applicable
Here is this code I have talking about

-------------snip

Private Sub CreateDivision()
Dim db As Database = HostApplicationServices.WorkingDatabase
Using trans As Transaction = db.TransactionManager.StartTransaction()
'First, get the NOD...
Dim NOD As DBDictionary = trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite, False)
'Define a corporate level dictionary
Dim acmeDict As DBDictionary
Try
'if it exists, just get it
acmeDict = trans.GetObject(NOD.GetAt("ACME_DIVISION"), OpenMode.ForRead)
Catch
'Doesn't exist, so create one
acmeDict = New DBDictionary()
NOD.SetAt("ACME_DIVISION", acmeDict)
trans.AddNewlyCreatedDBObject(acmeDict, True)
End Try

'Now get the division we want from acmeDict
Dim divDict As DBDictionary
Try
divDict = trans.GetObject(acmeDict.GetAt("Sales"), OpenMode.ForWrite)
Catch
divDict = New DBDictionary() 'Division doesn't exist, create one
acmeDict.UpgradeOpen()
acmeDict.SetAt("Sales", divDict)
trans.AddNewlyCreatedDBObject(divDict, True)
End Try

'Now get the manager info from the division
'We need to add the name of the division supervisor. We'll do this with another XRecord.
Dim mgrXRec As Xrecord
Try
mgrXRec = trans.GetObject(divDict.GetAt("Department Manager"), OpenMode.ForWrite)
Catch
mgrXRec = New Xrecord()
mgrXRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "Randolph P. Brokwell"))
divDict.SetAt("Department Manager", mgrXRec)
trans.AddNewlyCreatedDBObject(mgrXRec, True)
End Try
trans.Commit()
End Using
End Sub

---------snip

~'J'~
0 Likes
Message 12 of 20

Anonymous
Not applicable

This is what I have now.. (mostly from the labs).  But either my "get"
program is really wrong..  or the "set" does not work..?



Unfortunately the labs demo has the Xrecord attached to a block..  I
don't want it attached to anything..?



    <CommandMethod("test-set")> _

    Public Sub Create_Page_Xrecord() 'Public Sub
Create_Page_Xrecord(ByVal Page_String As String)

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)

            Dim TRKDict As DBDictionary

            Try

                TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"),
OpenMode.ForRead)

            Catch

                TRKDict = New DBDictionary

                NOD.SetAt("TRK Settings", TRKDict)

                trans.AddNewlyCreatedDBObject(TRKDict, True)

            End Try



            Dim PageDict As DBDictionary

            Try

                PageDict = trans.GetObject(TRKDict.GetAt("Page
Settings"), OpenMode.ForWrite)

            Catch

                PageDict = New DBDictionary()

                TRKDict.UpgradeOpen()

                TRKDict.SetAt("Page Settings", PageDict)

                trans.AddNewlyCreatedDBObject(PageDict, True)

            End Try



            Dim SettingsXRec As Xrecord

            Try

                SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForWrite)

            Catch

                SettingsXRec = New Xrecord()

                SettingsXRec.Data = New ResultBuffer(New
TypedValue(DxfCode.Text, "test"))

                PageDict.SetAt("Settings Info", SettingsXRec)

                trans.AddNewlyCreatedDBObject(SettingsXRec, True)

            End Try

            trans.Commit()

        Finally

            trans.Dispose()

        End Try

    End Sub



    <CommandMethod("test-get")> _

    Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord()
As String

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Dim DimsetXrecExists As Boolean = True

        Dim SettingsXRec As Xrecord

        Dim XrecValue As String

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)

            Dim TRKDict As DBDictionary =
trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)

            Dim PageDict As DBDictionary =
trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)

            SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForRead)

            XrecValue = SettingsXRec.Data.AsArray(0).ToString

        Catch

            DimsetXrecExists = False

        End Try

        If DimsetXrecExists Then

            'Read_Page_Xrecord = XrecValue

            MsgBox(XrecValue, MsgBoxStyle.Information)

        Else

            'Read_Page_Xrecord = ""

            MsgBox("nothing found", MsgBoxStyle.Information)

        End If

    End Sub





Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?



0 Likes
Message 13 of 20

Anonymous
Not applicable

ok, I've refined the code (and found the "error" i had before).   So I
can "set" and "read" the xrecord just like I did in VBA..  now I'm left
with how to I change it once created?    Can it be done (if so how?),
or do I have to recreate the xrecord (again, how?)?



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





C Witt wrote:

This is what I have now.. (mostly
from the labs).  But either my "get"
program is really wrong..  or the "set" does not work..?



Unfortunately the labs demo has the Xrecord attached to a block..  I
don't want it attached to anything..?



    <CommandMethod("test-set")> _

    Public Sub Create_Page_Xrecord() 'Public Sub
Create_Page_Xrecord(ByVal Page_String As String)

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)

            Dim TRKDict As DBDictionary

            Try

                TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"),
OpenMode.ForRead)

            Catch

                TRKDict = New DBDictionary

                NOD.SetAt("TRK Settings", TRKDict)

                trans.AddNewlyCreatedDBObject(TRKDict, True)

            End Try



            Dim PageDict As DBDictionary

            Try

                PageDict = trans.GetObject(TRKDict.GetAt("Page
Settings"), OpenMode.ForWrite)

            Catch

                PageDict = New DBDictionary()

                TRKDict.UpgradeOpen()

                TRKDict.SetAt("Page Settings", PageDict)

                trans.AddNewlyCreatedDBObject(PageDict, True)

            End Try



            Dim SettingsXRec As Xrecord

            Try

                SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForWrite)

            Catch

                SettingsXRec = New Xrecord()

                SettingsXRec.Data = New ResultBuffer(New
TypedValue(DxfCode.Text, "test"))

                PageDict.SetAt("Settings Info", SettingsXRec)

                trans.AddNewlyCreatedDBObject(SettingsXRec, True)

            End Try

            trans.Commit()

        Finally

            trans.Dispose()

        End Try

    End Sub



    <CommandMethod("test-get")> _

    Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord()
As String

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Dim DimsetXrecExists As Boolean = True

        Dim SettingsXRec As Xrecord

        Dim XrecValue As String

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)

            Dim TRKDict As DBDictionary =
trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)

            Dim PageDict As DBDictionary =
trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)

            SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForRead)

            XrecValue = SettingsXRec.Data.AsArray(0).ToString

        Catch

            DimsetXrecExists = False

        End Try

        If DimsetXrecExists Then

            'Read_Page_Xrecord = XrecValue

            MsgBox(XrecValue, MsgBoxStyle.Information)

        Else

            'Read_Page_Xrecord = ""

            MsgBox("nothing found", MsgBoxStyle.Information)

        End If

    End Sub





Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64
Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?





0 Likes
Message 14 of 20

Anonymous
Not applicable

Looks like that has been solved too.



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





C Witt wrote:

ok, I've refined the code (and found
the "error" i had before).   So I
can "set" and "read" the xrecord just like I did in VBA..  now I'm left
with how to I change it once created?    Can it be done (if so how?),
or do I have to recreate the xrecord (again, how?)?



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64
Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





C Witt wrote:

This is what I have now.. (mostly
from the labs).  But either my "get"
program is really wrong..  or the "set" does not work..?



Unfortunately the labs demo has the Xrecord attached to a block..  I
don't want it attached to anything..?



    <CommandMethod("test-set")> _

    Public Sub Create_Page_Xrecord() 'Public Sub
Create_Page_Xrecord(ByVal Page_String As String)

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)

            Dim TRKDict As DBDictionary

            Try

                TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"),
OpenMode.ForRead)

            Catch

                TRKDict = New DBDictionary

                NOD.SetAt("TRK Settings", TRKDict)

                trans.AddNewlyCreatedDBObject(TRKDict, True)

            End Try



            Dim PageDict As DBDictionary

            Try

                PageDict = trans.GetObject(TRKDict.GetAt("Page
Settings"), OpenMode.ForWrite)

            Catch

                PageDict = New DBDictionary()

                TRKDict.UpgradeOpen()

                TRKDict.SetAt("Page Settings", PageDict)

                trans.AddNewlyCreatedDBObject(PageDict, True)

            End Try



            Dim SettingsXRec As Xrecord

            Try

                SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForWrite)

            Catch

                SettingsXRec = New Xrecord()

                SettingsXRec.Data = New ResultBuffer(New
TypedValue(DxfCode.Text, "test"))

                PageDict.SetAt("Settings Info", SettingsXRec)

                trans.AddNewlyCreatedDBObject(SettingsXRec, True)

            End Try

            trans.Commit()

        Finally

            trans.Dispose()

        End Try

    End Sub



    <CommandMethod("test-get")> _

    Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord()
As String

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction =
db.transactionmanager.starttransaction

        Dim DimsetXrecExists As Boolean = True

        Dim SettingsXRec As Xrecord

        Dim XrecValue As String

        Try

            Dim NOD As DBDictionary =
trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)

            Dim TRKDict As DBDictionary =
trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)

            Dim PageDict As DBDictionary =
trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)

            SettingsXRec = trans.GetObject(PageDict.GetAt("Settings
Info"), OpenMode.ForRead)

            XrecValue = SettingsXRec.Data.AsArray(0).ToString

        Catch

            DimsetXrecExists = False

        End Try

        If DimsetXrecExists Then

            'Read_Page_Xrecord = XrecValue

            MsgBox(XrecValue, MsgBoxStyle.Information)

        Else

            'Read_Page_Xrecord = ""

            MsgBox("nothing found", MsgBoxStyle.Information)

        End If

    End Sub





Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64
Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?







0 Likes
Message 15 of 20

Anonymous
Not applicable
Sorry, your post are unreadable.

Try looking at one of your posts with Outlook Express

It's all gibberish.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5980821@discussion.autodesk.com...
This is what I have now.. (mostly from the labs). But either my "get" program is really wrong.. or the "set" does not work..?

Unfortunately the labs demo has the Xrecord attached to a block.. I don't want it attached to anything..?

   _
   Public Sub Create_Page_Xrecord() 'Public Sub Create_Page_Xrecord(ByVal Page_String As String)
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)
           Dim TRKDict As DBDictionary
           Try
               TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Catch
               TRKDict = New DBDictionary
               NOD.SetAt("TRK Settings", TRKDict)
               trans.AddNewlyCreatedDBObject(TRKDict, True)
           End Try

           Dim PageDict As DBDictionary
           Try
               PageDict = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForWrite)
           Catch
               PageDict = New DBDictionary()
               TRKDict.UpgradeOpen()
               TRKDict.SetAt("Page Settings", PageDict)
               trans.AddNewlyCreatedDBObject(PageDict, True)
           End Try

           Dim SettingsXRec As Xrecord
           Try
               SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForWrite)
           Catch
               SettingsXRec = New Xrecord()
               SettingsXRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "test"))
               PageDict.SetAt("Settings Info", SettingsXRec)
               trans.AddNewlyCreatedDBObject(SettingsXRec, True)
           End Try
           trans.Commit()
       Finally
           trans.Dispose()
       End Try
   End Sub

   _
   Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord() As String
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Dim DimsetXrecExists As Boolean = True
       Dim SettingsXRec As Xrecord
       Dim XrecValue As String
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)
           Dim TRKDict As DBDictionary = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Dim PageDict As DBDictionary = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)
           SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForRead)
           XrecValue = SettingsXRec.Data.AsArray(0).ToString
       Catch
           DimsetXrecExists = False
       End Try
       If DimsetXrecExists Then
           'Read_Page_Xrecord = XrecValue
           MsgBox(XrecValue, MsgBoxStyle.Information)
       Else
           'Read_Page_Xrecord = ""
           MsgBox("nothing found", MsgBoxStyle.Information)
       End If
   End Sub



Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?
0 Likes
Message 16 of 20

Anonymous
Not applicable
His posts show fine here in Outlook Express 6 - I only see the Â's in your post backs. Maybe a setting you have?

"Tony Tanzillo" wrote in message news:5981159@discussion.autodesk.com...
Sorry, your post are unreadable.

Try looking at one of your posts with Outlook Express

It's all gibberish.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5980821@discussion.autodesk.com...
This is what I have now.. (mostly from the labs). But either my "get" program is really wrong.. or the "set" does not work..?

Unfortunately the labs demo has the Xrecord attached to a block.. I don't want it attached to anything..?

   _
   Public Sub Create_Page_Xrecord() 'Public Sub Create_Page_Xrecord(ByVal Page_String As String)
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)
           Dim TRKDict As DBDictionary
           Try
               TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Catch
               TRKDict = New DBDictionary
               NOD.SetAt("TRK Settings", TRKDict)
               trans.AddNewlyCreatedDBObject(TRKDict, True)
           End Try

           Dim PageDict As DBDictionary
           Try
               PageDict = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForWrite)
           Catch
               PageDict = New DBDictionary()
               TRKDict.UpgradeOpen()
               TRKDict.SetAt("Page Settings", PageDict)
               trans.AddNewlyCreatedDBObject(PageDict, True)
           End Try

           Dim SettingsXRec As Xrecord
           Try
               SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForWrite)
           Catch
               SettingsXRec = New Xrecord()
               SettingsXRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "test"))
               PageDict.SetAt("Settings Info", SettingsXRec)
               trans.AddNewlyCreatedDBObject(SettingsXRec, True)
           End Try
           trans.Commit()
       Finally
           trans.Dispose()
       End Try
   End Sub

   _
   Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord() As String
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Dim DimsetXrecExists As Boolean = True
       Dim SettingsXRec As Xrecord
       Dim XrecValue As String
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)
           Dim TRKDict As DBDictionary = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Dim PageDict As DBDictionary = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)
           SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForRead)
           XrecValue = SettingsXRec.Data.AsArray(0).ToString
       Catch
           DimsetXrecExists = False
       End Try
       If DimsetXrecExists Then
           'Read_Page_Xrecord = XrecValue
           MsgBox(XrecValue, MsgBoxStyle.Information)
       Else
           'Read_Page_Xrecord = ""
           MsgBox("nothing found", MsgBoxStyle.Information)
       End If
   End Sub



Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?
0 Likes
Message 17 of 20

Anonymous
Not applicable
OE 6 here as well, everything set to defaults, with Unicode encoding.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"Paul Richardson" wrote in message news:5981169@discussion.autodesk.com...
His posts show fine here in Outlook Express 6 - I only see the Â's in your post backs. Maybe a setting you have?

"Tony Tanzillo" wrote in message news:5981159@discussion.autodesk.com...
Sorry, your post are unreadable.

Try looking at one of your posts with Outlook Express

It's all gibberish.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5980821@discussion.autodesk.com...
This is what I have now.. (mostly from the labs). But either my "get" program is really wrong.. or the "set" does not work..?

Unfortunately the labs demo has the Xrecord attached to a block.. I don't want it attached to anything..?

   _
   Public Sub Create_Page_Xrecord() 'Public Sub Create_Page_Xrecord(ByVal Page_String As String)
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)
           Dim TRKDict As DBDictionary
           Try
               TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Catch
               TRKDict = New DBDictionary
               NOD.SetAt("TRK Settings", TRKDict)
               trans.AddNewlyCreatedDBObject(TRKDict, True)
           End Try

           Dim PageDict As DBDictionary
           Try
               PageDict = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForWrite)
           Catch
               PageDict = New DBDictionary()
               TRKDict.UpgradeOpen()
               TRKDict.SetAt("Page Settings", PageDict)
               trans.AddNewlyCreatedDBObject(PageDict, True)
           End Try

           Dim SettingsXRec As Xrecord
           Try
               SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForWrite)
           Catch
               SettingsXRec = New Xrecord()
               SettingsXRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "test"))
               PageDict.SetAt("Settings Info", SettingsXRec)
               trans.AddNewlyCreatedDBObject(SettingsXRec, True)
           End Try
           trans.Commit()
       Finally
           trans.Dispose()
       End Try
   End Sub

   _
   Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord() As String
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Dim DimsetXrecExists As Boolean = True
       Dim SettingsXRec As Xrecord
       Dim XrecValue As String
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)
           Dim TRKDict As DBDictionary = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Dim PageDict As DBDictionary = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)
           SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForRead)
           XrecValue = SettingsXRec.Data.AsArray(0).ToString
       Catch
           DimsetXrecExists = False
       End Try
       If DimsetXrecExists Then
           'Read_Page_Xrecord = XrecValue
           MsgBox(XrecValue, MsgBoxStyle.Information)
       Else
           'Read_Page_Xrecord = ""
           MsgBox("nothing found", MsgBoxStyle.Information)
       End If
   End Sub



Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?
0 Likes
Message 18 of 20

Anonymous
Not applicable

They look fine to me (checked outlook on another computer).   Only your
posts show that extra formatting..?



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

OE 6 here as well, everything set to defaults, with Unicode encoding.



0 Likes
Message 19 of 20

Anonymous
Not applicable
Paul Richardson wrote:

> His posts show fine here in Outlook Express 6 ...

Also look fine in Thunderbird 2.0.

Terry
0 Likes
Message 20 of 20

Anonymous
Not applicable
I was using Western European - changing to Unicode 8 does not give me any Â's. Maybe because
I've already downloaded his posts. We'll see with future posts...

"Tony Tanzillo" wrote in message news:5981200@discussion.autodesk.com...
OE 6 here as well, everything set to defaults, with Unicode encoding.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"Paul Richardson" wrote in message news:5981169@discussion.autodesk.com...
His posts show fine here in Outlook Express 6 - I only see the Â's in your post backs. Maybe a setting you have?

"Tony Tanzillo" wrote in message news:5981159@discussion.autodesk.com...
Sorry, your post are unreadable.

Try looking at one of your posts with Outlook Express

It's all gibberish.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"C Witt" wrote in message news:5980821@discussion.autodesk.com...
This is what I have now.. (mostly from the labs). But either my "get" program is really wrong.. or the "set" does not work..?

Unfortunately the labs demo has the Xrecord attached to a block.. I don't want it attached to anything..?

   _
   Public Sub Create_Page_Xrecord() 'Public Sub Create_Page_Xrecord(ByVal Page_String As String)
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectsdictionaryid, OpenMode.ForWrite, False)
           Dim TRKDict As DBDictionary
           Try
               TRKDict = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Catch
               TRKDict = New DBDictionary
               NOD.SetAt("TRK Settings", TRKDict)
               trans.AddNewlyCreatedDBObject(TRKDict, True)
           End Try

           Dim PageDict As DBDictionary
           Try
               PageDict = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForWrite)
           Catch
               PageDict = New DBDictionary()
               TRKDict.UpgradeOpen()
               TRKDict.SetAt("Page Settings", PageDict)
               trans.AddNewlyCreatedDBObject(PageDict, True)
           End Try

           Dim SettingsXRec As Xrecord
           Try
               SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForWrite)
           Catch
               SettingsXRec = New Xrecord()
               SettingsXRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, "test"))
               PageDict.SetAt("Settings Info", SettingsXRec)
               trans.AddNewlyCreatedDBObject(SettingsXRec, True)
           End Try
           trans.Commit()
       Finally
           trans.Dispose()
       End Try
   End Sub

   _
   Public Sub Read_Page_Xrecord() 'Public Function Read_Page_Xrecord() As String
       Dim db = HostApplicationServices.WorkingDatabase
       Dim trans As Transaction = db.transactionmanager.starttransaction
       Dim DimsetXrecExists As Boolean = True
       Dim SettingsXRec As Xrecord
       Dim XrecValue As String
       Try
           Dim NOD As DBDictionary = trans.GetObject(db.namedobjectdictionaryid, OpenMode.ForRead, False)
           Dim TRKDict As DBDictionary = trans.GetObject(NOD.GetAt("TRK Settings"), OpenMode.ForRead)
           Dim PageDict As DBDictionary = trans.GetObject(TRKDict.GetAt("Page Settings"), OpenMode.ForRead)
           SettingsXRec = trans.GetObject(PageDict.GetAt("Settings Info"), OpenMode.ForRead)
           XrecValue = SettingsXRec.Data.AsArray(0).ToString
       Catch
           DimsetXrecExists = False
       End Try
       If DimsetXrecExists Then
           'Read_Page_Xrecord = XrecValue
           MsgBox(XrecValue, MsgBoxStyle.Information)
       Else
           'Read_Page_Xrecord = ""
           MsgBox("nothing found", MsgBoxStyle.Information)
       End If
   End Sub



Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
I didn't know the labs had an XRecprd example.

Why didn't you go through the labs in the first place?
0 Likes