<?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: VB.NET accessing property set data in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117134#M76389</link>
    <description>Thank you for your reply,&lt;BR /&gt;
&lt;BR /&gt;
I think my issue is the way im getting the aec object from the using input. I get the following error when i run the below code, "Unable to cast object of type 'Autodesk Aec.Structural.DatabaseServices.Member' to type 'Autodesk.AutoCAD.Interop.Common.AcadObject'&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Imports Autodesk.AEC.Interop.Schedule&lt;BR /&gt;
Imports Autodesk.AEC.Interop.ArchBase&lt;BR /&gt;
&lt;BR /&gt;
Namespace Selection&lt;BR /&gt;
&lt;BR /&gt;
    Public Class AcEdSSGetCommand&lt;BR /&gt;
&lt;BR /&gt;
        Shared SelentityCount As Integer = 0&lt;BR /&gt;
        Shared UseThisSelectionResult As PromptSelectionResult&lt;BR /&gt;
        Shared UseThisSelectionOption As PromptSelectionOptions = Nothing&lt;BR /&gt;
&lt;BR /&gt;
        'This command allows only a single entity to be picked&lt;BR /&gt;
        &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
        Public Sub singlePick()&lt;BR /&gt;
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
            Dim Opts As New PromptSelectionOptions()&lt;BR /&gt;
            Opts.AllowDuplicates = True&lt;BR /&gt;
            Opts.MessageForAdding = "Select entities"&lt;BR /&gt;
            Dim res As PromptSelectionResult = ed.GetSelection(Opts)&lt;BR /&gt;
&lt;BR /&gt;
            If res.Status = PromptStatus.Error Then&lt;BR /&gt;
                Return&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
            Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value&lt;BR /&gt;
            Dim idarray As ObjectId() = SS.GetObjectIds()&lt;BR /&gt;
&lt;BR /&gt;
            Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
            Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager&lt;BR /&gt;
&lt;BR /&gt;
            Dim myT As Transaction = tm.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                Dim id As ObjectId&lt;BR /&gt;
                For Each id In idarray&lt;BR /&gt;
                    Dim ent As Entity = tm.GetObject(id, OpenMode.ForWrite, True)&lt;BR /&gt;
                    Dim Sched As New AecScheduleApplication&lt;BR /&gt;
                    Dim PropSets As AecSchedulePropertySets&lt;BR /&gt;
                    Dim propSet As AecSchedulePropertySet&lt;BR /&gt;
                    Dim i As Integer&lt;BR /&gt;
                    PropSets = Sched.PropertySets(ent)&lt;BR /&gt;
                    For i = 0 To PropSets.Count - 1&lt;BR /&gt;
                        propSet = PropSets.Item(i)&lt;BR /&gt;
                        If propSet.Name = "3-NZS3604Joists" Then&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected: " + propSet.Name))&lt;BR /&gt;
                        Else&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected 2: " + propSet.Name))&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    Next&lt;BR /&gt;
                Next id&lt;BR /&gt;
            Finally&lt;BR /&gt;
                myT.Dispose()&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Sub 'singlePick&lt;BR /&gt;
    End Class 'AcEdSSGetCommand&lt;BR /&gt;
End Namespace 'Selection&lt;BR /&gt;
&lt;BR /&gt;
I think i am almost there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/COMMANDMETHOD&gt;</description>
    <pubDate>Sun, 18 Nov 2007 20:39:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-11-18T20:39:41Z</dc:date>
    <item>
      <title>VB.NET accessing property set data</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117132#M76387</link>
      <description>Hi, I wish to migrate my VBA code into VB.NET.&lt;BR /&gt;
&lt;BR /&gt;
Here is a snippet of the code i use in VBA. From the research i have done i believe the below is possible in VB.NET too, with the addition of some libaries.&lt;BR /&gt;
&lt;BR /&gt;
Could someone please provide the libaries required and/or sample code of how to achieve the below in VB.NET&lt;BR /&gt;
&lt;BR /&gt;
Dim Sched As New AecScheduleApplication&lt;BR /&gt;
Dim PropSets As AecSchedulePropertySets&lt;BR /&gt;
Dim propSet As AecSchedulePropertySet&lt;BR /&gt;
Dim Prop As AecScheduleProperty&lt;BR /&gt;
Set PropSets = Sched.PropertySets(vDoor)&lt;BR /&gt;
For i = 0 To PropSets.Count - 1&lt;BR /&gt;
Set propSet = PropSets.Item(i)&lt;BR /&gt;
If propSet.name = vpropSet Then&lt;BR /&gt;
ansi = i&lt;BR /&gt;
Exit For&lt;BR /&gt;
End If&lt;BR /&gt;
Next i&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards &lt;BR /&gt;
&lt;BR /&gt;
Chris</description>
      <pubDate>Wed, 14 Nov 2007 19:34:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117132#M76387</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-14T19:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET accessing property set data</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117133#M76388</link>
      <description>In your vb net project you need to add reference's to the AEC libraries. In Visual Studio goto the 'Project' menu, select 'Add Reference...', click on the 'COM' tab and scroll down until you see the libraries starting with 'AEC'. You should add 'AEC Base', 'AEC Architectural', and 'AEC Schedule'&lt;BR /&gt;
&lt;BR /&gt;
The library versions depend on what version of AutoCAD/Architectural you are using. I am using 2008 and those libraries are:&lt;BR /&gt;
AEC Architectural 5.5 Application Library&lt;BR /&gt;
AEC Architectural 5.5 Object Library&lt;BR /&gt;
AEC Base 5.5 Application Library&lt;BR /&gt;
AEC Base 5.5 Object Library&lt;BR /&gt;
AEC Schedule 5.5 Object Library&lt;BR /&gt;
&lt;BR /&gt;
Also scroll down until you see 'AutoCAD/ObjectDBX Common **.* Type Library' and add that as well.&lt;BR /&gt;
&lt;BR /&gt;
Also make sure your project has references to &lt;BR /&gt;
'acmgd &amp;amp; acdbmgd'.&lt;BR /&gt;
&lt;BR /&gt;
Add these to the top of your code file:&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Imports Autodesk.AEC.Interop.Schedule&lt;BR /&gt;
Imports Autodesk.AEC.Interop.ArchBase&lt;BR /&gt;
&lt;BR /&gt;
I got your code to compile in VS 2005 using AutoCAD MEP 2008 which has Archtectural.</description>
      <pubDate>Sat, 17 Nov 2007 10:32:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117133#M76388</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2007-11-17T10:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET accessing property set data</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117134#M76389</link>
      <description>Thank you for your reply,&lt;BR /&gt;
&lt;BR /&gt;
I think my issue is the way im getting the aec object from the using input. I get the following error when i run the below code, "Unable to cast object of type 'Autodesk Aec.Structural.DatabaseServices.Member' to type 'Autodesk.AutoCAD.Interop.Common.AcadObject'&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Imports Autodesk.AEC.Interop.Schedule&lt;BR /&gt;
Imports Autodesk.AEC.Interop.ArchBase&lt;BR /&gt;
&lt;BR /&gt;
Namespace Selection&lt;BR /&gt;
&lt;BR /&gt;
    Public Class AcEdSSGetCommand&lt;BR /&gt;
&lt;BR /&gt;
        Shared SelentityCount As Integer = 0&lt;BR /&gt;
        Shared UseThisSelectionResult As PromptSelectionResult&lt;BR /&gt;
        Shared UseThisSelectionOption As PromptSelectionOptions = Nothing&lt;BR /&gt;
&lt;BR /&gt;
        'This command allows only a single entity to be picked&lt;BR /&gt;
        &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
        Public Sub singlePick()&lt;BR /&gt;
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
            Dim Opts As New PromptSelectionOptions()&lt;BR /&gt;
            Opts.AllowDuplicates = True&lt;BR /&gt;
            Opts.MessageForAdding = "Select entities"&lt;BR /&gt;
            Dim res As PromptSelectionResult = ed.GetSelection(Opts)&lt;BR /&gt;
&lt;BR /&gt;
            If res.Status = PromptStatus.Error Then&lt;BR /&gt;
                Return&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
            Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value&lt;BR /&gt;
            Dim idarray As ObjectId() = SS.GetObjectIds()&lt;BR /&gt;
&lt;BR /&gt;
            Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
            Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager&lt;BR /&gt;
&lt;BR /&gt;
            Dim myT As Transaction = tm.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                Dim id As ObjectId&lt;BR /&gt;
                For Each id In idarray&lt;BR /&gt;
                    Dim ent As Entity = tm.GetObject(id, OpenMode.ForWrite, True)&lt;BR /&gt;
                    Dim Sched As New AecScheduleApplication&lt;BR /&gt;
                    Dim PropSets As AecSchedulePropertySets&lt;BR /&gt;
                    Dim propSet As AecSchedulePropertySet&lt;BR /&gt;
                    Dim i As Integer&lt;BR /&gt;
                    PropSets = Sched.PropertySets(ent)&lt;BR /&gt;
                    For i = 0 To PropSets.Count - 1&lt;BR /&gt;
                        propSet = PropSets.Item(i)&lt;BR /&gt;
                        If propSet.Name = "3-NZS3604Joists" Then&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected: " + propSet.Name))&lt;BR /&gt;
                        Else&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected 2: " + propSet.Name))&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    Next&lt;BR /&gt;
                Next id&lt;BR /&gt;
            Finally&lt;BR /&gt;
                myT.Dispose()&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Sub 'singlePick&lt;BR /&gt;
    End Class 'AcEdSSGetCommand&lt;BR /&gt;
End Namespace 'Selection&lt;BR /&gt;
&lt;BR /&gt;
I think i am almost there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/COMMANDMETHOD&gt;</description>
      <pubDate>Sun, 18 Nov 2007 20:39:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117134#M76389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-18T20:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET accessing property set data</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117135#M76390</link>
      <description>I think the problem is that you're mixing the&lt;BR /&gt;
managed and COM APIs.&lt;BR /&gt;
&lt;BR /&gt;
In the line:&lt;BR /&gt;
&lt;BR /&gt;
    PropSets = Sched.PropertySets(ent);&lt;BR /&gt;
&lt;BR /&gt;
The 'ent' parameter is a managed object, which &lt;BR /&gt;
you're passing to a COM object. The COM object &lt;BR /&gt;
doesn't know what a managed object is.&lt;BR /&gt;
&lt;BR /&gt;
Try:&lt;BR /&gt;
&lt;BR /&gt;
   PropSets = Sched.PropertySets(ent.AcadObject);&lt;BR /&gt;
&lt;BR /&gt;
Managed and COM apis are not interoperable,&lt;BR /&gt;
so you can't pass managed objects to COM&lt;BR /&gt;
APIs or visa verse. The AcadObject property of&lt;BR /&gt;
the managed wrapper for an entity, is its COM&lt;BR /&gt;
wrapper. You can go the other way (e.g., from&lt;BR /&gt;
the COM wrapper to the managed wrapper) with&lt;BR /&gt;
the DBObject.FromAcadObject() method.&lt;BR /&gt;
&lt;BR /&gt;
Always investigate to see if there is a managed&lt;BR /&gt;
API that can do what a COM API does, and try to&lt;BR /&gt;
use the managed API if available.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;CHRIS&gt; wrote in message news:5780672@discussion.autodesk.com...&lt;BR /&gt;
Thank you for your reply,&lt;BR /&gt;
&lt;BR /&gt;
I think my issue is the way im getting the aec object from the using input. I get the following error when i run the below code, "Unable to cast object of type 'Autodesk Aec.Structural.DatabaseServices.Member' to type 'Autodesk.AutoCAD.Interop.Common.AcadObject'&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Imports Autodesk.AEC.Interop.Schedule&lt;BR /&gt;
Imports Autodesk.AEC.Interop.ArchBase&lt;BR /&gt;
&lt;BR /&gt;
Namespace Selection&lt;BR /&gt;
&lt;BR /&gt;
    Public Class AcEdSSGetCommand&lt;BR /&gt;
&lt;BR /&gt;
        Shared SelentityCount As Integer = 0&lt;BR /&gt;
        Shared UseThisSelectionResult As PromptSelectionResult&lt;BR /&gt;
        Shared UseThisSelectionOption As PromptSelectionOptions = Nothing&lt;BR /&gt;
&lt;BR /&gt;
        'This command allows only a single entity to be picked&lt;BR /&gt;
        &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
        Public Sub singlePick()&lt;BR /&gt;
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
            Dim Opts As New PromptSelectionOptions()&lt;BR /&gt;
            Opts.AllowDuplicates = True&lt;BR /&gt;
            Opts.MessageForAdding = "Select entities"&lt;BR /&gt;
            Dim res As PromptSelectionResult = ed.GetSelection(Opts)&lt;BR /&gt;
&lt;BR /&gt;
            If res.Status = PromptStatus.Error Then&lt;BR /&gt;
                Return&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
            Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value&lt;BR /&gt;
            Dim idarray As ObjectId() = SS.GetObjectIds()&lt;BR /&gt;
&lt;BR /&gt;
            Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
            Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager&lt;BR /&gt;
&lt;BR /&gt;
            Dim myT As Transaction = tm.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                Dim id As ObjectId&lt;BR /&gt;
                For Each id In idarray&lt;BR /&gt;
                    Dim ent As Entity = tm.GetObject(id, OpenMode.ForWrite, True)&lt;BR /&gt;
                    Dim Sched As New AecScheduleApplication&lt;BR /&gt;
                    Dim PropSets As AecSchedulePropertySets&lt;BR /&gt;
                    Dim propSet As AecSchedulePropertySet&lt;BR /&gt;
                    Dim i As Integer&lt;BR /&gt;
                    PropSets = Sched.PropertySets(ent)&lt;BR /&gt;
                    For i = 0 To PropSets.Count - 1&lt;BR /&gt;
                        propSet = PropSets.Item(i)&lt;BR /&gt;
                        If propSet.Name = "3-NZS3604Joists" Then&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected: " + propSet.Name))&lt;BR /&gt;
                        Else&lt;BR /&gt;
                            ed.WriteMessage((ControlChars.Lf + "You selected 2: " + propSet.Name))&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    Next&lt;BR /&gt;
                Next id&lt;BR /&gt;
            Finally&lt;BR /&gt;
                myT.Dispose()&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Sub 'singlePick&lt;BR /&gt;
    End Class 'AcEdSSGetCommand&lt;BR /&gt;
End Namespace 'Selection&lt;BR /&gt;
&lt;BR /&gt;
I think i am almost there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/COMMANDMETHOD&gt;&lt;/CHRIS&gt;</description>
      <pubDate>Mon, 19 Nov 2007 13:59:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-accessing-property-set-data/m-p/2117135#M76390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-19T13:59:30Z</dc:date>
    </item>
  </channel>
</rss>

