Author Topic: Palette Problem  (Read 22840 times)

0 Members and 1 Guest are viewing this topic.

DBARANAS

  • Guest
Re: Palette Problem
« Reply #45 on: August 18, 2006, 02:54:42 AM »
Mick

I see you were trying to use objects in a grid.

Everything I make in the models gets serialized into binary files. All the objectID's are in those files.

I can fake it and fill the grid and get the same result, because I get things from those files

 I don't know if this helps, but it is an approach I took because it was all I knew and hacked something up to get around my lack of knowledge.


MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #46 on: August 18, 2006, 04:47:51 AM »
The main reason I need a prop's dialog is simply to view/update data (xdata in this case) stored on any particular object. This way I let autocad look after my data as well as the object's.
You could also use xrecords which have a huge potential capacity for data storage but half the data I need needs to be updated with object modifications which with the right type, xdata can do this automatically.
The other half could be serialized out but it's easier just to store it with all the other data as xdata, this allows you to copy and paste into other drawings also and the objects take the xdata with them.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #47 on: August 18, 2006, 06:37:10 AM »
I see...different apps...different methods.

I just found a good property grid example that shows how to add more cool stuff. Now I can lose the code for managing rows and collumns and take advantage of having combos and collapsable rows for arrays and points,etc.

This is as good as it gets. I got it plugged in and working. I never could have figured this way out...but now I see it and can learn from it

I converted it for you C sharpers. I had to comment out a couple of things to get it running in C# but it does most everything

smcclure

  • Guest
Re: Palette Problem
« Reply #48 on: August 18, 2006, 10:27:36 AM »
Ok, this is an unorthodox way of setting entity prop's but I needed it to get and set some xdata but this simple app shows what I was trying to do.

I would like to throw in a suggestion to think about using ICustomTypeDescriptor and PropertyDescriptor to dynamically add/remove properties from the class. I have an example, but it is not ACAD specific if people are interested. Basically, though, you just need to override getProperties in ICustomTypeDescriptor and return whatever PropertyDescriptors you want. It beats making custom classes just to interface with the PropertyGrid.

That said, I dont like PropertyGrid very much and I would suggest a DataGridView instead. The PropertyGrid is a kind of a kluged afterthought, and things like ErrorProviders do not work with it. The DataGridView I believe is a much more robust control.

smcclure

  • Guest
Re: Palette Problem
« Reply #49 on: August 18, 2006, 10:29:42 AM »
Also you should use an ExpandableObjectConverter for any custom objects that have internal properties that must be set for PropertyGrids. It makes that cool collapsible editor that you see for arrays and such.

 - Scott

DBARANAS

  • Guest
Re: Palette Problem
« Reply #50 on: August 18, 2006, 10:51:43 AM »
That said, I dont like PropertyGrid very much and I would suggest a DataGridView instead. The PropertyGrid is a kind of a kluged afterthought, and things like ErrorProviders do not work with it. The DataGridView I believe is a much more robust control.

I saw benefits I could not easily do with a datagridview that I could do more easily with the property grid. So I basically did a 180 yesterday.

But I am not going to able to just throw the datagridview away either. I have lots of dynamic list(of t) made up of classes that I need to have in grids as well

I am interested in seeing your example as I am trying to connect up my existing classes to the grid.



EDIT: Fixed those quote tags for ya
« Last Edit: August 18, 2006, 11:30:21 AM by nivuahc »

smcclure

  • Guest
Re: Palette Problem
« Reply #51 on: August 18, 2006, 04:07:39 PM »
But I am not going to able to just throw the datagridview away either. I have lots of dynamic list(of t) made up of classes that I need to have in grids as well

These can be used inside a PropertyGrid using the method I described above. I tried to pull my example out but I found that there were a ton of dependencies - it is part of the preferences system that my appliication uses, so it has a lot of dependencies. I found a link that describes the method I used more concisely than my code does (it doesnt have the extra junk...) It is available at The Code Project: http://www.codeproject.com/cs/miscctrl/bending_property.asp
« Last Edit: August 18, 2006, 04:08:40 PM by smcclure »

DBARANAS

  • Guest
Re: Palette Problem
« Reply #52 on: August 18, 2006, 09:57:32 PM »
These can be used inside a PropertyGrid using the method I described above. I tried to pull my example out but I found that there were a ton of dependencies - it is part of the preferences system that my appliication uses, so it has a lot of dependencies. I found a link that describes the method I used more concisely than my code does (it doesnt have the extra junk...) It is available at The Code Project: http://www.codeproject.com/cs/miscctrl/bending_property.asp
[/quote]

Thanks!

I think I saw that one during my DataGridView quest. Noiw it makes sense to me and I am working on getting it over to VB to play with it.

Glenn R

  • Guest
Re: Palette Problem
« Reply #53 on: August 19, 2006, 09:18:53 AM »
Quote
Everything I make in the models gets serialized into binary files. All the objectID's are in those files

I really don't see how that's possible, as an ObjectID is a calculated property off the handle. Meaning, a handle is guaranteed to be unique for a file (and autocad files these out in save ops) but is not guaranteed to be unique across multiple drawings. An ObjectID on the otherhand, is guarnateed to be unique across a session as it's calculated off the handle..................................................

DBARANAS

  • Guest
Re: Palette Problem
« Reply #54 on: August 20, 2006, 12:25:48 PM »
Quote
Everything I make in the models gets serialized into binary files. All the objectID's are in those files

I really don't see how that's possible, as an ObjectID is a calculated property off the handle. Meaning, a handle is guaranteed to be unique for a file (and autocad files these out in save ops) but is not guaranteed to be unique across multiple drawings. An ObjectID on the otherhand, is guarnateed to be unique across a session as it's calculated off the handle..................................................

Glenn please explain some more you have me confused.

I can say that everything that I do lives in a single .dwg file
I don't do anything with xrefs or blocks outside of the file I am working in
I keep the project in its own directory with all of the *.dat binary files I create.
I can open up any model and bring things back from the dead and work on them (object ID's or handles (..old VBA))

You have me wondering now. I have been too busy writing lines to test out different scenarios.
If I can store object ID's in a binary file and load them up when I open a project then that is all I need if the objectId's are still the same and I can manipulate solids,etc in a new sesion.

I have had a few problems where the objectID's (or handles) could not drill the AcDB and return objects back to me. I have been ignoring this trying to get the rest of the code up and running.

Since I went .net I haven't seen this in a while and forgot about it

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palette Problem
« Reply #55 on: August 20, 2006, 05:04:02 PM »
Dave,
The Handle is stored in the drawing file and is never reused in the same drawing.
An Object ID is assigned when the drawing is opened and may/will be different for each session.
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.

Glenn R

  • Guest
Re: Palette Problem
« Reply #56 on: August 20, 2006, 07:00:32 PM »
What Kerry said.

When a drawing is filed in (DwgFiler from memory) it comes across a handle stored in the dwg and reads it in, then it CALCULATES the objectID based of the handle, the document id and possibly even a session id. The upshot of this is, is that an objectid is a RUNTIME thing and should never be counted on to be the same from drawing to drawing/session to session.

If you need that functionality, store the handle and tie it to a particular drawing.

smcclure

  • Guest
Re: Palette Problem
« Reply #57 on: August 21, 2006, 10:41:58 AM »
Everything I make in the models gets serialized into binary files. All the objectID's are in those files.

If you are using the included .NET serialization functionality, I would watch out. It doesnt appear that the AutoCAD objects are marked as serializable. I would suggest writing each object out manually (using the handle as described below) or, if you are feeling adventurous, make a wrapper object that is serialized has some serializable fields that will write out the handle and retrieve the object from the handle for you.

DBARANAS

  • Guest
Re: Palette Problem
« Reply #58 on: August 23, 2006, 12:46:53 AM »
What Kerry said.

if you need that functionality, store the handle and tie it to a particular drawing.

I hope I got it right. This is what I am doing

make something....

            Dim solid As Solid3d = New Solid3d()
            solid.Extrude(region, height, 0)

            'add it to the db
            btr.AppendEntity(solid)
            trans.AddNewlyCreatedDBObject(solid, True)
            handle = solid.ObjectId.Handle.Value.ToString()  'is this a handle or an objectID?

get it back later......

                    Dim id As ObjectId = db.GetObjectId(False, New Handle(Convert.ToInt64(.silPltHnd)), 0)' same thing here again
                    Dim doclock As DocumentLock = AcAp.DocumentManager.MdiActiveDocument.LockDocument()
                    Dim ent As Entity = DirectCast(trans.GetObject(id, DatabaseServices.OpenMode.ForWrite), Entity)
                    Dim solid As Solid3d = DirectCast(ent, Solid3d)

I am doing this everywhere...I know this thread is going sideways. But now I am not so sure about this

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #59 on: August 23, 2006, 01:33:19 AM »
The way you're getting the handle seems ok (I do the same but using an array of id's) so it should be fine.
A way to check is to "LIST" your object with a known handle and see if it indeed exports and imports the same object.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien