Skip to content

Conversation

@vitspec99
Copy link

@vitspec99 vitspec99 commented Dec 15, 2025

PR for issue-2954

Description

New function load_family2() introduced.
It loads Family and returns list[DB.FamilySymbol] of loaded Family or empty list of error occured.


Checklist

Before submitting your pull request, ensure the following requirements are met:

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black using the command:
    pipenv run black {source_file_or_directory}
  • Changes are tested and verified to work as expected.

Related Issues


Thank you for contributing to pyRevit! 🎉

@devloai
Copy link
Contributor

devloai bot commented Dec 15, 2025

Unable to trigger custom agent "Code Reviewer"You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new function load_family2() to provide an alternative family loading method that returns a list of loaded family symbols instead of a boolean result.

Key changes:

  • Added load_family2() function that loads a family file and returns all family symbols from the loaded family
  • Returns an empty list on error or if the family is already loaded, rather than a boolean


res = doc.LoadFamily(family_file, FamilyLoaderOptionsHandler(), ret_ref)

if ( res != True ):
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing boolean values using != True is redundant. Use if not res: instead for more idiomatic Python code.

Suggested change
if ( res != True ):
if not res:

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be fixed @vitspec99

res = doc.LoadFamily(family_file, FamilyLoaderOptionsHandler(), ret_ref)

if ( res != True ):
mlogger.debug("Cann't load Family from file=%s. It's may be OK if Family already loaded.", family_file)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Cann't' to 'Cannot' and 'It's may be' to 'It may be'.

Suggested change
mlogger.debug("Cann't load Family from file=%s. It's may be OK if Family already loaded.", family_file)
mlogger.debug("Cannot load Family from file=%s. It may be OK if Family already loaded.", family_file)

Copilot uses AI. Check for mistakes.
@jmcouffin
Copy link
Contributor

Thinking out loud here:
Why not modifying the original load_family function adding a default arg to trigger a different output?

@vitspec99

@vitspec99
Copy link
Author

It was my thought too. But I decide to start new function firstly and if function idea usefull and code is OK original load_family() interface/code may be changed.

@jmcouffin
Copy link
Contributor

Can you make a pass on copilot's comments please @vitspec99

@jmcouffin jmcouffin changed the title Dev/2954 Feat: load_family() returning elements Dec 21, 2025
@jmcouffin jmcouffin changed the title Feat: load_family() returning elements feat: load_family() returning elements Dec 21, 2025
@jmcouffin jmcouffin marked this pull request as draft January 6, 2026 21:05
@jmcouffin
Copy link
Contributor

Please implement directly this change to hte original function load_family and do not add a new function
The original one seems to be used once in the entire codebase here

if create.load_family(family_file, doc=doc):

so if you fix the above and its usage in the ensure module, this should be good enough for me to review and test
also, for good measure, provide a minimal example of its usage and output so that it becomes easier to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

revit.create.load_family2() to return family symbols like revit.query.get_family()

2 participants