Author Topic: Linetype is purged  (Read 10223 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #15 on: April 11, 2008, 05:58:05 PM »
Kerry, I was actually not using your XML file, is that the problem?  I was just passing the Linetype name I wanted manually thru code
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: Linetype is purged
« Reply #16 on: April 11, 2008, 05:58:44 PM »
can you post or send the XML definition file, just for completeness.

My eyes are hanging out of my head on stalks at the moment and I might have missed something, but...what XML file?

Duh,

What have you tried exactly? What stumped you about Tony's implementation?

Cheers,
Glenn.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #17 on: April 11, 2008, 06:04:32 PM »
Glenn, Kerry's code has a part where he reads an XML file and creates layers based on the file.  I can post it if you need it.

The part that is stumping me is I am not sure what Im supposed to pass to his code to grab the "erased" id.  I'm also assuming you used the second piece(s) of code as that was being touted as faster/better.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Linetype is purged
« Reply #18 on: April 11, 2008, 06:05:27 PM »
can you post or send the XML definition file, just for completeness.

My eyes are hanging out of my head on stalks at the moment and I might have missed something, but...what XML file?

< ... >
Cheers,
Glenn.

        static public void createLayerXML(string Lname)
        {
  //*

...
*//
                {
                    DataSet dsLayerData = new DataSet();
                    dsLayerData.ReadXml(@"c:\LayerDefinitions.xml");
                    DataView dsLayerDefinition = new DataView(dsLayerData.Tables["Layer"]);
                    dsLayerDefinition.Sort = "LayerName";
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #19 on: April 11, 2008, 06:16:24 PM »
I copied this into my code
Code: [Select]
//      // This is a much better/faster solution that P/Invokes
//      // AcDbSymbolTableRecord::getAt() directly from managed code:


        public static class AcDbSymbolTable
        {
            // Acad::ErrorStatus AcDbSymbolTable::getAt(wchar_t const *, class AcDbObjectId &, bool)

            [System.Security.SuppressUnmanagedCodeSecurity]
            [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode,
               EntryPoint = "?getAt@AcDbSymbolTable@@QBE?AW4ErrorStatus@Acad@@PB_WAAVAcDbObjectId@@_N@Z")]

            public static extern ErrorStatus getAt(IntPtr symbolTable, string name, out ObjectId id, bool getErased);
        }

        public static ObjectId GetSymbolTableRecordId(SymbolTable table, string name)
        {
            ObjectId id = ObjectId.Null;
            ErrorStatus es = AcDbSymbolTable.getAt(table.UnmanagedObject, name, out id, false);
            return id;
        }

        public static ObjectId GetSymbolTableRecordId(ObjectId TableId, string name)
        {
            using (Transaction tr = TableId.Database.TransactionManager.StartTransaction())
            {
                SymbolTable table = (SymbolTable)tr.GetObject(TableId, OpenMode.ForRead);
                try
                {
                    return GetSymbolTableRecordId(table, name);
                }
                finally
                {
                    tr.Commit();
                }
            }
        }
and then was trying to figure out what to pass to which function to get the ID of the erased Linetype, and then trying to figure out how to unerase it.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: Linetype is purged
« Reply #20 on: April 11, 2008, 06:17:03 PM »
Very quick and off the top of my head from looking at Tony's code again:

Code: [Select]
Database db = ...;

ObjectId someLinetypeTableRecordId = ObjectId.Null;

someLinetypeTableRecordId = DBUtils.GetSymbolTableRecordId(db.LinetypeTableRecord, "SomeLineTypeNameGoesHere");

if (someLinetypeTableRecordId != ObjectId.Null)
  // do some funky mojo here...


Glenn R

  • Guest
Re: Linetype is purged
« Reply #21 on: April 11, 2008, 06:18:26 PM »
You REALLY don't want to UNERASE it. Read the discussion I posted earlier from the Adesk NG where Tony and I were discussing this particular problem.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Linetype is purged
« Reply #22 on: April 11, 2008, 06:21:20 PM »
FYI....

If you want to test if an ObjectId is Null, you can just use the property 'IsNull'.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #23 on: April 14, 2008, 10:52:52 AM »
I must need more coffee, b/c I just re read the discussion b/t you and TT, and I just dont get it.  What I think I am supposed to do is check for the name and if its erased, create a new one.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Linetype is purged
« Reply #24 on: April 14, 2008, 11:19:04 AM »
I must need more coffee, b/c I just re read the discussion b/t you and TT, and I just dont get it.  What I think I am supposed to do is check for the name and if its erased, create a new one.
That is how I do it in an insert block routine I just did, so I hope it is the right approach.  Mine works without crashing, so I figured it was a good solution.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #25 on: April 14, 2008, 11:20:09 AM »
Thanks Tim.  I'll try and post what I got if I get to it today.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: Linetype is purged
« Reply #26 on: April 14, 2008, 11:49:36 AM »
I must need more coffee, b/c I just re read the discussion b/t you and TT, and I just dont get it.  What I think I am supposed to do is check for the name and if its erased, create a new one.

Essentially, yes.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #27 on: April 14, 2008, 04:32:49 PM »
Thanks Glenn!  Only being able to look at this stuff every couple of weeks makes it very difficult to keep rational thoughts about what I was/am doing, and where I need to go.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #28 on: May 27, 2008, 02:31:04 PM »
wow, looking at my last post, and then checking the date, its been a while.  Oh well, I have 2 days to work on this, and then I'm gone for a week.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Linetype is purged
« Reply #29 on: May 27, 2008, 02:53:01 PM »
Well, I have some very good news!!!!!  It looks like they fixed the problem in 2009  :lol: :lol: :lol:  I loaded 09 last week, and just for grins decided to tell VS2008 to use 09.  Not remembering where I was with the whole problem, I began stepping thru the code to repeat the problem, and it ran flawlessly.  More testing to follow, but I think it is golden with regard to erased records
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)