jeremytammik / RevitLookup

Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
http://thebuildingcoder.typepad.com
MIT License
1.03k stars 294 forks source link

An extension to show associated family parameters #175

Closed CADBIMDeveloper closed 1 year ago

CADBIMDeveloper commented 1 year ago

Summary of the Pull Request

What is this about: Added an ability to show associated family parameters Description: lookup

Quality Checklist

Issues (the PR is a draft now)

  1. it requires the magic to make the family parameter snoopable:
    public sealed class FamilyParameterDescriptor : Descriptor, IDescriptorResolver // <-- !!!
    {
    ...
    public ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters)
    {
        return null; // <-- !!!
    }
    }

    otherwise it shows a non-snoopable text like: non-snoopable

if I remove FamilyParameterDescriptor registration (what I obviously don't want to do :-)) https://github.com/jeremytammik/RevitLookup/blob/f52d2fef57c27159d0029866daba12bf482c5351/RevitLookup/Core/ComponentModel/DescriptorMap.cs#L68, it also becomes snoopable: snoopable-if-remove-the descriptor

@Nice3point , you know the codebase much deeper than me, probably, it's better if you'll fix it :-)

  1. As a suggestion would be nice to extend IExtensionManager or DescriptorExtension to be able to control when the extension should be added, for example adding another extension registration method like:
void Register<T>(T value, Action<DescriptorExtension<T>> extension, Func<DescriptorExtension<T>, bool> isActive);

So we'll avoid adding GetAssociateFamilyParameters extension in non-family editor contexts

Nice3point commented 1 year ago

@CADBIMDeveloper

  1. реализуй IDescriptorCollector вместо IDescriptorResolver https://github.com/jeremytammik/RevitLookup/blob/dev/Contributing.md#idescriptorcollector

    Это работает потому что IDescriptorResolver уже реализует IDescriptorCollector и позволяет снупить объект https://github.com/jeremytammik/RevitLookup/blob/dev/Contributing.md#idescriptorcollector

    Ну а удаление строчки из DescriptorMap позволяет снупить потому что этот класс FamilyParameter наследуется от ApiObject, который уже и так зарегистрирован, лукап использует более базовый класс, вот и вся магия

  2. Можно обойтись и без этой перегрузки, а просто добавить обычный if перед регистрацией расширения

    
    if(_parameter.Element.Document.IsFamilyDocument)
    {
        manager.Register(...);
    }
CADBIMDeveloper commented 1 year ago

Ок, завтра)

P.S. IDescriptorCollector проморгал как-то

Nice3point commented 1 year ago

Да давай) без проблем

CADBIMDeveloper commented 1 year ago

@Nice3point , привет.

я чуток по другому сделал вместо:

if(_parameter.Element.Document.IsFamilyDocument)

IExtensionManager теперь имеет публичное свойство документа.

Мотивация: не у всего в API можно достучаться до документа, т.е. либо передавать в Descriptor ещё и документ (что ИМХО, не очень) либо не иметь возможности делать больше Extension-ов.

Пример - тот самый FamilyParameter. Там есть простор для того, чтобы расширять его Extension-ами с доступом через FamilyManager

Nice3point commented 1 year ago

Привет, да я тоже думал там документ свойством потом сделать именно для этого. Спасибо что сделал это сам. Я гляну Pr чуть позже как за комп сяду)

Nice3point commented 1 year ago

@jeremytammik hey Jeremy, what about checking the PR and getting everything agreed? (

jeremytammik commented 1 year ago

hi roman, i did not translate the russian, and assumed that my agreement was required purely pro forma. the RevitLookup coding has reached a point now that exceeds my competence. i trust and hope that i can leave it in your capable hands to check. is that OK?

CADBIMDeveloper commented 1 year ago

Sorry, Jeremy :-) @Nice3point , we should use English here

Nice3point commented 1 year ago

@jeremytammik Yes, Jeremy no problem, we will discuss it in English, it was just quicker to solve the problem in the native language. I can merge the PRs myself, it's fine)

jeremytammik commented 1 year ago

Thank you! That is a relief!