Hi, im trying to write a script that will change the ‘Start / End Join Cutback’ parameter.
Problem is that the values in the project are 1.27 while in Revit Lookup and my code I get 0.
class ISelectionFilter_beams(ISelectionFilter):
def AllowElement(self, element):
"""overriding existing method
you can add more checks
if you get an error it wont be shown and False will be returned"""
if type(element) == FamilyInstance and element.Category.Name == 'Structural Framing':
return True
# create instance from new class
beam_filter = ISelectionFilter_beams()
# invoke selection and filter
ref_picked_beams = [selection.PickObjects(ObjectType.Element, beam_filter)]
picked_beams = [doc.GetElement(ref) for ref in ref_picked_beams]
if (picked_beams):
for beam in picked_beams:
param_start_join_cutback = beam.get_Parameter(BuiltInParameter.START_JOIN_CUTBACK)
param_end_join_cutback = beam.get_Parameter(BuiltInParameter.END_JOIN_CUTBACK)
print('start join cutback: {}'.format(param_start_join_cutback.AsInteger()))
print('end join cutback: {}'.format(param_end_join_cutback.AsInteger()))
else:
print('No selected beams')
# ---------------------------------------------------------
print(50 * '-')
print('Script -{}- has finished running'.format(__title__))
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
# 0️⃣ collect
beams = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralFraming).WhereElementIsNotElementType().ToElements()
# 1️⃣ start extension
startPoints = [i.get_Parameter(BuiltInParameter.START_EXTENSION).AsDouble() for i in beams]
# 2️⃣ end extension
endPoints = [i.get_Parameter(BuiltInParameter.END_EXTENSION).AsDouble() for i in beams]
# ✅ result
for i in zip(startPoints,endPoints):
print(i)
Thank you. I assumed its an int (even though its not a whole number ) and didnt check the storage type.
But even when i use the AsDouble() method I still dont get that 1.27.
Maybe its because of the data structure Double?
I dont see something similar to 1.27 or 0.0127 in your prints as well…
@andreasd811 ,
It appears so that the actual value in Revit is stored in feet but the properties in my project are set to cm.
Is it right to assume that all length are stored in feet?
How can I know the measuring unit for each parameter?
Sounds exhausting to try to match everything…
@andreasd811 ,
So let me see if i got it right,
Where I from we work with the metric system and if I want for example to set the length of some element to lets say 1.5m, I have to:
convert the 1.5m to feet
parameter.Set(‘new_length’)
transaction.commit()
Or in simple words commit the values in Imperial system only?