Closed jmcouffin closed 5 months ago
I just posted a pull request that should fix this. It basically mimics how pyRevit imports wpf. I will leave it to the team to decide whether or now we want to intentionally leave the rpw stale in order to move off of it over time or not. I know this update caused some pain for my company who was relying heavily on rpw forms.
I will check this out
fixed by #2188
Thanks for this, I had trouble with rpw, because IPY2711PR engine had pyRevitLabs.IronPython.Wpf
so clr.AddReference('IronPython.Wpf')
threw an exception
NOTE: below is just an investigation on the original issue, which seems to be solved by the related PR
Okay, so the original issue of LoadComponent
is happening in Revit 2022, but in 2023, 2024 it breaks with the IOException
when trying to load the IronPython.Wpf
assembly. Anyone knows why does it act differently?
Edit:
found the reason: IronPython.Wpf is already preloaded by Dynamo, so clr
finds it and it doesn't try to load from pyrevit bin
IronPython.Wpf 2.7.9.0 C:\Program Files\Autodesk\Revit 2022\AddIns\DynamoForRevit\IronPython.Wpf.dll
Thats why we have IronPython.Wpf in 2022, that breaks, but nothing in 2023, 2024
tried it in 2024 2023 2021 I will try it in 2022 then
tried the pychilizer room data sheet tool from that
from pyrevit import revit, DB, script, forms
from rpw.ui.forms import FlexForm, Label, TextBox, Button, ComboBox, CheckBox, Separator
import rdslocator, rdsui
from itertools import izip
import sys
from pychilizer import units, select, geo, database
from Autodesk.Revit import Exceptions
ui = rdsui.UI(script)
ui.is_metric = units.is_metric
doc = __revit__.ActiveUIDocument.Document
output = script.get_output()
logger = script.get_logger() # helps to debug script, not used
selection = select.select_with_cat_filter(DB.BuiltInCategory.OST_Rooms, "Pick Rooms for Room Data Sheets")
# collect all view templates for plans and sections
viewsections = DB.FilteredElementCollector(doc).OfClass(DB.ViewSection) # collect sections
ui.viewsection_dict = {v.Name: v for v in viewsections if v.IsTemplate} # only fetch the IsTemplate sections
viewplans = DB.FilteredElementCollector(doc).OfClass(DB.ViewPlan) # collect plans
ui.viewplan_dict = {v.Name: v for v in viewplans if v.IsTemplate} # only fetch IsTemplate plans
ui.viewport_dict = {database.get_name(v): v for v in
database.get_viewport_types(doc)} # use a special collector w viewport param
ui.set_vp_types()
# add none as an option
ui.viewsection_dict["<None>"] = None
ui.viewplan_dict["<None>"] = None
ui.set_viewtemplates()
ui.set_viewtemplates()
# collect titleblocks in a dictionary
titleblocks = DB.FilteredElementCollector(doc).OfCategory(
DB.BuiltInCategory.OST_TitleBlocks).WhereElementIsElementType().ToElements()
if not titleblocks:
forms.alert("There are no Titleblocks loaded in the model.", exitscript=True)
ui.titleblock_dict = {'{} : {}'.format(tb.FamilyName, revit.query.get_name(tb)): tb for tb in titleblocks}
ui.set_titleblocks()
view_scale = 50
# get units for Crop Offset variable
if units.is_metric(doc):
unit_sym = " [mm]"
else:
unit_sym = " [decimal feet]"
components = [
Label("Select Titleblock"),
ComboBox(name="tb", options=sorted(ui.titleblock_dict), default=database.tb_name_match(ui.titleblock, doc)),
Label("Sheet Number"),
TextBox("sheet_number", Text=ui.sheet_number),
Label("Crop offset" + unit_sym),
TextBox("crop_offset", Text=str(ui.crop_offset)),
Label("Titleblock (internal) offset" + unit_sym),
TextBox("titleblock_offset", Text=str(ui.titleblock_offset)),
Label("Layout orientation"),
ComboBox(name="layout_orientation", options=ui.layout_orientation, default=ui.layout_ori),
CheckBox("el_rotation", 'Rotate elevations', default=ui.rotated_elevations),
CheckBox("el_as_sec", 'Elevations as Sections', default=ui.el_as_sec),
Label("Titleblock orientation"),
ComboBox(name="tb_orientation", options=ui.tblock_orientation, default=ui.titleblock_orientation),
Separator(),
Label("View Template for Plans"),
ComboBox(name="vt_plans", options=sorted(ui.viewplan_dict), default=database.vt_name_match(ui.viewplan, doc)),
Label("View Template for Reflected Ceiling Plans"),
ComboBox(name="vt_rcp_plans", options=sorted(ui.viewplan_dict),
default=database.vt_name_match(ui.viewceiling, doc)),
Label("View Template for Elevations"),
ComboBox(name="vt_elevs", options=sorted(ui.viewsection_dict), default=database.vt_name_match(ui.viewsection, doc)),
Label("Viewport Type"),
ComboBox(name="vp_types", options=sorted(ui.viewport_dict), default=database.vp_name_match(ui.viewport, doc)),
Separator(),
Button("Select"),
]
form = FlexForm("Set Sheet Number", components)
ok = form.show()
it works fine in 2022... @thumDer
Sorry for the confusion but I was talking about the situation before the related pull request, how the original rpw wpf referencing worked, just wanted to investigate. I should have been more specific.
for reference, interactions with ipy3, rps, ipy2, wpf https://github.com/architecture-building-systems/revitpythonshell/issues/155#issuecomment-2049190852
✈ Pre-Flight checks
🐞 Describe the bug
While using rpw flexform module and the LoadComponent, the code context seems to not go through. The issue occured previously.
I will document the issue later.
⌨ Error/Debug Message
♻️ To Reproduce
Ipy 2711 Import row flexform Use the LoadComponent () method
⏲️ Expected behavior
No response
🖥️ Hardware and Software Setup (please complete the following information)
Additional context
No response