Im getting an module object has no attribute error using the a pyrevit function. Im not sure it isnt working. I had it working on my home pc but for some reason wont work on work pc.
import clr
import pyrevit
from pyrevit import *
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
def get_parameter_value_by_name(element, parameterName):
return element.LookupParameter(parameterName).AsValueString()
#Select elements from revit.
selection = [doc.GetElement(x) for x in uidoc.Selection.GetElementIds()]
for s in selection:
locationcurve = s.Location.Curve
beam_start_point = locationcurve.GetEndPoint(0)
beam_end_point = locationcurve.GetEndPoint(1)
converted_start_point = pyrevit.revit.geom.convert_point_to_metric(beam_start_point)
converted_end_point = pyrevit.revit.geom.convert_point_to_metric(beam_end_point)
I did some troubleshooting and have narrowed down the issue a little further. Hopefully this extra information helps track down the issue.
If i replace a script in the pyrevit toolbar with my script it will run. However it will only run after i run another command from the pyrevit menu. Then it will continiue to run fine.
If i run it from my extension tab. it wont ever work. regardless if i run other commands before it.
If i copy a pyrevit command to my extension that uses the pyrevit module, it will run fine.
a script on my extension that doesnt use the pyrevit module will also run fine.
I hope this makes sense. The version of pyrevit i installed was the public release version exe. not the commandline in case this makes a difference.