Code Red > .NET

SetExtensionDictionaryEntryFilter Method

(1/4) > >>

Augusto:
Hello everyone. I've been experimenting with Overrule in AutoCAD's .NET API but encountered recursive method calls when creating objects in WorldDraw using 'myObject.WorldDraw(wd);'. Also, within the polylines I aim to apply Overrule on, there are some data inserted using a specific method.


--- Code - C#: --- // Set XRecordpublic void StoreBlockData(ObjectId blockId, double diameter, string type){    using (Transaction tr = blockId.Database.TransactionManager.StartTransaction())    {        DBObject obj = tr.GetObject(blockId, OpenMode.ForWrite);         DBDictionary extDict;        if (obj.ExtensionDictionary.IsNull)        {            obj.CreateExtensionDictionary();            extDict = (DBDictionary)tr.GetObject(obj.ExtensionDictionary, OpenMode.ForWrite);        }        else        {            extDict = (DBDictionary)tr.GetObject(obj.ExtensionDictionary, OpenMode.ForWrite);        }         // Store Diameter        Xrecord diameterXRec = new Xrecord { Data = new ResultBuffer(new TypedValue((int)DxfCode.Real, diameter)) };        extDict.SetAt("Diameter", diameterXRec);        tr.AddNewlyCreatedDBObject(diameterXRec, true);         // Store Type        Xrecord typeXRec = new Xrecord { Data = new ResultBuffer(new TypedValue((int)DxfCode.Text, type)) };        extDict.SetAt("Type", typeXRec);        tr.AddNewlyCreatedDBObject(typeXRec, true);         tr.Commit();    }}  
Could anyone provide insights or examples on how the 'SetExtensionDictionaryEntryFilter' method operates to help manage these scenarios?

I didn't find usage examples in the documentation. https://help.autodesk.com/view/OARX/2022/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_GraphicsInterface_DrawableOverrule_SetExtensionDictionaryEntryFilter_string

Forgive me if the answer is in front of me, but I wasn't able to find it.

Thank you in advance, Luís Augusto

edit Kerry : add code tags for formatting [ code = csharp ]  with no spaces

Augusto:
I found this example that uses a filter for XDATA that utilizes the application name. The filter is set during the initialization of the PipeOverrule class with the command SetXDataFilter(regAppName);

This actually works, i.e., it eliminates the unnecessary call of the WorldDraw method, but as Kean himself said, it might be that in the future XDATA won't be viable for the application, so we can use entries from the extension dictionary.

This is where I'm not understanding. The SetExtensionDictionaryEntryFilter() filtering method expects a string entryName.

https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_GraphicsInterface_DrawableOverrule_SetExtensionDictionaryEntryFilter_string

Does anyone have any idea on how to use this method?

I will attach the classes that are on the website.

https://www.keanw.com/2009/04/optimized-overruling-in-autocad-2010-using-net.html

Sincerely, Luís Augusto.

gile:
Hi,

Here's an example which uses an extension dictionary entry instead of extension data.
Only the PipeOverrule is affected by this modification.
Accessing to an xrecord in the extension dictionary of a DBObject is not as trivial as accessing to its xdata. To do it, I used some extension methods extracted from this library.

Augusto:
Wow! It worked perfectly, Gile!
Thank you so much for your generosity in sharing the example and also your library. I'm sure I'll use some of your solutions. This is very valuable for the learning phase I'm in. I can't thank you enough.

Leveraging your knowledge, I'd like to ask you another question.
When you say that 'Accessing to an xrecord in the extension dictionary of a DBObject is not as trivial as accessing to its xdata', is there any downside in your view regarding performance, or is it just a matter of ease of use of xdata?

gile:

--- Quote from: Augusto on March 07, 2024, 08:29:12 AM ---When you say that 'Accessing to an xrecord in the extension dictionary of a DBObject is not as trivial as accessing to its xdata', is there any downside in your view regarding performance, or is it just a matter of ease of use of xdata?

--- End quote ---
IMHO, it is not a question of performance. To read or write xrecord data, you need more code (i.e. the extension methods).

Navigation

[0] Message Index

[#] Next page

Go to full version