I am working with the Revit API and I have some trouble executing this piece of code. I am aware that 'out' parameters in C# are not respected in Python, so I am asking if there is any way to convert this method to Python code so it can be executed.
I leave here the link to the Revit API documentation:
https://www.revitapidocs.com/2020/5d34b8dd-9137-da2f-9df7-172304d0cc08.htm
Thanks in advance.
C# version:
public class FamilyLoadOptions : IFamilyLoadOptions
{
public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
{
overwriteParameterValues = true;
return true;
}
public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
{
source = FamilySource.Family;
overwriteParameterValues = true;
return true;
}
}
Family loadedFamily = null;
var success = doc.LoadFamily(localPath, new FamilyLoadOptions(), out loadedFamily);
My version in Python:
class FamilyLoadOptions(IFamilyLoadOptions):
def OnFamilyLoad(familyInUse, overwriteParameterValues):
overwriteParameterValues = True
return True
def OnsharedFamilyFound(sharedFamily, familyInUse, source, overwriteParameterValues):
overwriteParameterValues = True
return True
ref = clr.Reference[Family]()
doc.LoadFamily(familyPath, FamilyLoadOptions(), ref)
question from:
https://stackoverflow.com/questions/66051463/how-to-convert-a-c-sharp-method-that-use-an-out-parameter-to-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…