Author Topic: How can I to get the list of all types which objects are available in a drawing  (Read 9039 times)

0 Members and 1 Guest are viewing this topic.

owenwengerd

  • Bull Frog
  • Posts: 451
I stand corrected. I didn't know they exposed the DWG filer in the .NET API.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
2 TheMaster
Thank you very much. I try to understand your code. Earlier I never worked with the class DwgFiler.

Your code isn't compiled, since it is necessary to realize 44 more abstract members. :(
« Last Edit: June 20, 2012, 03:18:18 AM by Andrey »

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Code: [Select]
// Pass the Id of the object to find references to:
  public RefSearchFiler( ObjectId referencedId )  {
    this.referencedId = referencedId;
  }
  // Search the parameter for references to the referencedId:
  public void Find( DBObject obj )
  {
    this.current = obj;
    try
    {
      obj.DwgOut( this );
    }
    finally
    {
      this.current = null;
    }
  }
Probably I incorrectly translate comments into Russian...
Quote
Pass the Id of the object to find references to:
If I want to find all objects which use "MyTextStyle"text style, then should I pass the identifier (ObjectId) of this text style in parameter?

Quote
// Search the parameter for references to the referencedId:
Should  I specify object of my text style (TextStyleTableRecord) as parameter?

Regards
« Last Edit: June 20, 2012, 06:08:21 AM by Andrey »

TheMaster

  • Guest
I thank all for answers. I will compare speeds of performance of a code.

It is very strange, since there is a lot of such tasks...
For example:
it is necessary to remove text style. But this style can be used by different primitives (the text, the sizes, attributes, etc.) therefore at first it is necessary to find all these primitives in a database and to appoint by it other text style. These primitives can be anywhere. The similar task can arise and for other styles: dimensional styles, table styles, etc.


The process of grouping all objects in a drawing by their runtime class takes as long
as simply searching all objects for references directly, and as soon as the user gets
control again, you can't rely on the cached results of the grouping because they are
no longer valid.

If you are trying to find references to multiple objects, that can be done as well with
a single pass over the database.

Quote
Above I specified an example. I hope, this example gives the clear answer to your question: it is necessary to look for everywhere since the necessary objects can be anywhere. If not to find at least one, then it will not be possible to remove text style.

Sorry, no. I have written quite a bit of code that finds references to a single object
as well as multiple objects, and there has never been a need to group objects by
their type or runtime class, and doing that would not make the process any faster.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
... and there has never been a need to group objects by
their type or runtime class, and doing that would not make the process any faster.
Sorry for my bad English.
Example:
I must will do next operations:
1. To check that all dimensions contain the correct values (not manually changed).
2. To check all text and multileader objects on compliance to a rule (regular expression) and if will be found - to do necessary changes (replace old values on new values by other regular expression).
3. To check that all text, the sizes, multileaders and hatches are on the necessary layers.
4. etc.

For the solution of these tasks, I want to lock  Database for external changes, then having executed once iteration - to create the dictionary Dictionary<string, List<ObjectId>>. Average speed of obtaining such dictionary - 1-1,5 second for 1 000 000 objects (for my computer). But then, having received the objects of ObjectId grouped in type, it will be simpler to me to carry out the tasks. For example, it is convenient to use LINQ for collection processing. After task performance I will unlock Database.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Why not perform those task on the first iteration?  Why iterate to obtain ObjectIds just so you can iterate them again?  You could find out the object type from the ObjectId and if it's an object you are looking for, do what you want to it then.
Revit 2019, AMEP 2019 64bit Win 10

Andrey Bushman

  • Swamp Rat
  • Posts: 864
2 MexicanCustard
May be you are right, but I will leave this method just in case (cases be are different).

2 TheMaster
What about my questions?

I received the answer from ADN, but unfortunately their code works incorrectly. Probably I was misunderstood by developers of Autodesk. I reported to them about it.