Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kevin

Pages: [1]
1
Events / Re: EventHandler for Entity Selection
« on: November 25, 2012, 04:17:24 PM »
I´m trying to get all entites (ids...) which are currently selected for displaying xdatas
in a palette.
If I select for example lines I want the ObjectIds saved in a Collection or array. If I unselect
the Entity/ies I want to remove the Id from the Collection.
If I run a command or something else, the Entites will be unselected too, but with the Method
ed.SelectionRemoved the entite Ids wont be removed / the event isnt fired.

And I dont want to run a command, this should be "interactive" like the autocad property palette...



2
Events / Re: EventHandler for Entity Selection
« on: November 25, 2012, 12:41:00 PM »
Hi,

now I tried it with ed.SelectionAdded and ed.SelectionRemoved.

The problem now is:
If I dont deselect the entity direct, it will be further in my ObjectIdCollection.

The adding Code looks like that:

Code: [Select]
public static void ed_SelectionAdded(object sender, SelectionAddedEventArgs e)
        {
            Document doc = MgdAcApplication.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            ObjectId[] ids = e.AddedObjects.GetObjectIds();

            foreach (ObjectId id in ids)
            {
                if (!IdCollection.Contains(id))
                {
                    IdCollection.Add(id);
                }
            }
        } 

My main problem is, that the SelectionRemoved only fires if the entity is directly deselected.

Do you have any idea?

Many thanks!

3
Events / EventHandler for Entity Selection
« on: November 23, 2012, 08:15:16 PM »
Hi everybody,

Im looking for an eventHandler which will be fired if I have selected an entity.
I tried it with PromptForEntityEndingEventHandler but the event will be fired everytime
I cross an entity.

Do you know a simple example of that?

Kind regards,
Kevin

4
External databases / Re: Saving Custom Data
« on: November 04, 2012, 05:58:24 PM »
Perfect! Thank you very much.
I will give it a try.

 :solved:

5
External databases / Re: Saving Custom Data
« on: November 04, 2012, 12:50:07 PM »
Now I tried to save custom data.

I write to Functions. An AutoCad function and a static one.

AutoCad Code is:
Code: [Select]
[CommandMethod.....]
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Transaction tr = ed.Document.Database.TransactionManager.StartTransaction();
PromptEntityResult getEntityResult = ed.GetEntity("Select Entity to Dic");

ObjectId new = new ObjectId();
new = getEntityResult.ObjectId;
StaticMethods.AddCustomData(new, tr, ed, true);

The second code is:
Code: [Select]
public static bool AddCustomData(ObjectId id, Transaction trans, Editor ed, bool add)
{
trans = ed.Document.Database.TransactionManager.StartTransaction()
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForRead);
ent.UpgradeOpen();
ent.CreateExtensionDictionary();
DBDictionary extDictionary = (DBDictionary)trans.GetObject(ent.ExtensionDictionary, OpenMode.ForWrite);
Xrecord xrec = new Xrecord();
extDictionary.SetAt("CustomData", xrec);
trans.AddNewlyCreatedDBObject(xrec, true);
trans.Commit();
}

I get no error and the ID is transfered.
If I do this in one function the result will be most ok, not everytime.

My second problem is... How is the right syntax of the following code?
Code: [Select]
ResultBuffer dataResBuf = new ResultBuffer(new TypedValue((int)DxfCode.Thickness, 5), new TypedValue((int)DxfCode.Real, 35));
xrec.Data = dataResBuf;

Thank you.

Kind regards,
Kevin

6
External databases / Saving Custom Data
« on: October 16, 2012, 12:38:26 AM »
Hi Everybody,

I have a question.
I have created a class called "NewLine" that inherits from Line. Now I have
added some further properties. Strings, ints and so on.

Which opportunity do I have for saving my custom Data in the dwg?
I know Dictionaries but is there a better way?

Kind Regards,
Kevin

7
That is what I was looking for.
 
That will help me very much!

Thanks.

8
Selection sets / Small Sample for selecting lines and reading coordinates
« on: October 09, 2012, 10:00:19 PM »
Hi everybody,

Im looking for a Sample for selecting all lines.
After that i want to read the coordinates.

Sorry im a noob, so could someone give me a link for solving my Problem, please.

Thank you!

Regards

Pages: [1]