# -*- coding: utf-8 -*- try: from pyrevit.versionmgr import PYREVIT_VERSION except: from pyrevit import versionmgr PYREVIT_VERSION = versionmgr.get_pyrevit_version() pyRevitNewer44 = PYREVIT_VERSION.major >= 4 and PYREVIT_VERSION.minor >= 5 if pyRevitNewer44: from pyrevit import script from pyrevit.forms import WPFWindow, alert my_config = script.get_config() else: from scriptutils import this_script as script from scriptutils.userinput import WPFWindow, pick_folder my_config = script.config from Autodesk.Revit.UI import TaskDialog def alert(msg): TaskDialog.Show('pyrevit', msg) import show_dependent_defaults as cdef import pyapex_utils as pau class ShowDependentConfigWindow(WPFWindow):
"""List Project Symbols tool config """ from pyrevit import revit, script, DB, forms config = script.get_config() custom_config = script.get_config("List Project Symbolsconfig") # list of symbol categories categories = [ DB.BuiltInCategory.OST_DoorTags, DB.BuiltInCategory.OST_WindowTags, DB.BuiltInCategory.OST_RoomTags, DB.BuiltInCategory.OST_AreaTags, DB.BuiltInCategory.OST_WallTags, DB.BuiltInCategory.OST_CurtainWallPanelTags, DB.BuiltInCategory.OST_SectionHeads, DB.BuiltInCategory.OST_CalloutHeads, DB.BuiltInCategory.OST_CeilingTags, DB.BuiltInCategory.OST_FurnitureTags, DB.BuiltInCategory.OST_PlumbingFixtureTags, DB.BuiltInCategory.OST_ReferenceViewerSymbol, DB.BuiltInCategory.OST_GridHeads, DB.BuiltInCategory.OST_LevelHeads, DB.BuiltInCategory.OST_SpotElevSymbols, DB.BuiltInCategory.OST_ElevationMarks, DB.BuiltInCategory.OST_StairsTags, DB.BuiltInCategory.OST_StairsLandingTags, DB.BuiltInCategory.OST_StairsRunTags, DB.BuiltInCategory.OST_StairsSupportTags, DB.BuiltInCategory.OST_BeamSystemTags, DB.BuiltInCategory.OST_StructuralFramingTags, DB.BuiltInCategory.OST_ViewportLabel ]
def __init__(self, xaml_file_name, reset_config=False): forms.WPFWindow.__init__(self, xaml_file_name) # verify keynote file existence self._kfile = revit.query.get_keynote_file(doc=revit.doc) if not self._kfile or not op.exists(self._kfile): self._kfile = None forms.alert("Keynote file is not accessible. " "Please select a keynote file.") self._change_kfile() # if a keynote file is still not set, return if not self._kfile: raise Exception('Keynote file is not setup.') # if a keynote file is still not set, return if not os.access(self._kfile, os.W_OK): raise Exception('Keynote file is read-only.') self._conn = None try: self._conn = kdb.connect(self._kfile) except System.TimeoutException as toutex: forms.alert(toutex.Message, expanded="{}::__init__()".format( self.__class__.__name__), exitscript=True) except Exception as ex: logger.debug('Connection failed | %s' % ex) res = forms.alert( "Existing keynote file needs to be converted to " "a format usable by this tool. The resulting keynote " "file is still readble by Revit and could be shared " "with other projects. Users should NOT be making changes to " "the existing keynote file during the conversion process.\n" "Are you sure you want to convert?", options=["Convert", "Select a different keynote file", "Give me more info"]) if res: if res == "Convert": try: self._convert_existing() forms.alert("Conversion completed!") if not self._conn: forms.alert( "Launch the tool again to manage keynotes.", exitscript=True ) except Exception as convex: logger.debug('Legacy conversion failed | %s' % convex) forms.alert("Conversion failed! %s" % convex, exitscript=True) elif res == "Select a different keynote file": self._change_kfile() elif res == "Give me more info": script.open_url(__helpurl__) #pylint: disable=undefined-variable script.exit() else: forms.alert("Keynote file is not yet converted.", exitscript=True) self._cache = [] self._allcat = kdb.RKeynote(key='', text='-- ALL CATEGORIES --', parent_key='', locked=False, owner='', children=None) self._needs_update = False self._config = script.get_config() self._used_keysdict = self.get_used_keynote_elements() self.load_config(reset_config) self.search_tb.Focus()
"""Use FreeForm or Extrusion """ # Select between two methods of creating geometry for rooms: Extrusion will create an extrusion based # on the outline of the room. Freeform will create a non-parameteric shape that is true to room solid. # An example where this can be useful is when you want to represent a room with sloped top (when attached # to a roof) import sys from pyrevit import script, DB from rpw.ui.forms import FlexForm, Label, ComboBox, Button custom_config = script.get_config("Room to GM") #todo: add location for the template def get_config(): prev_cats = custom_config.get_option("chosen_method", []) return prev_cats def config_method(): prev_choice = get_config() opts = ["Extrusion", "Freeform"] components = [ Label("Choose method:"), ComboBox(name="method", options=opts, default=prev_choice), Button("Remember choice") ]
def __init__(self, xaml_file_name): forms.WPFWindow.__init__(self, xaml_file_name) self._config = script.get_config() # base self.halftone.IsChecked = \ self._config.get_option('halftone', True) self.transparency.IsChecked = \ self._config.get_option('transparency', True) # projection lines self.proj_line_color.IsChecked = \ self._config.get_option('proj_line_color', True) self.proj_line_pattern.IsChecked = \ self._config.get_option('proj_line_pattern', True) self.proj_line_weight.IsChecked = \ self._config.get_option('proj_line_weight', True) # projection forground pattern self.proj_fill_color.IsChecked = \ self._config.get_option('proj_fill_color', True) self.proj_fill_pattern.IsChecked = \ self._config.get_option('proj_fill_pattern', True) self.proj_fill_pattern_visibility.IsChecked = \ self._config.get_option('proj_fill_pattern_visibility', True) # projection background pattern (Revit >= 2019) if HOST_APP.is_newer_than(2019, or_equal=True): self.proj_bg_fill_color.IsChecked = \ self._config.get_option('proj_bg_fill_color', True) self.proj_bg_fill_pattern.IsChecked = \ self._config.get_option('proj_bg_fill_pattern', True) self.proj_bg_fill_pattern_visibility.IsChecked = \ self._config.get_option('proj_bg_fill_pattern_visibility', True) # cut lines self.cut_line_color.IsChecked = \ self._config.get_option('cut_line_color', True) self.cut_line_pattern.IsChecked = \ self._config.get_option('cut_line_pattern', True) self.cut_line_weight.IsChecked = \ self._config.get_option('cut_line_weight', True) # cut forground pattern self.cut_fill_color.IsChecked = \ self._config.get_option('cut_fill_color', True) self.cut_fill_pattern.IsChecked = \ self._config.get_option('cut_fill_pattern', True) self.cut_fill_pattern_visibility.IsChecked = \ self._config.get_option('cut_fill_pattern_visibility', True) # cut background pattern (Revit >= 2019) if HOST_APP.is_newer_than(2019, or_equal=True): self.cut_bg_fill_color.IsChecked = \ self._config.get_option('cut_bg_fill_color', True) self.cut_bg_fill_pattern.IsChecked = \ self._config.get_option('cut_bg_fill_pattern', True) self.cut_bg_fill_pattern_visibility.IsChecked = \ self._config.get_option('cut_bg_fill_pattern_visibility', True) # dim overrides self.dim_override.IsChecked = \ self._config.get_option('dim_override', True) self.dim_textposition.IsChecked = \ self._config.get_option('dim_textposition', False) self.dim_above.IsChecked = self._config.get_option('dim_above', True) self.dim_below.IsChecked = self._config.get_option('dim_below', True) self.dim_prefix.IsChecked = self._config.get_option('dim_prefix', True) self.dim_suffix.IsChecked = self._config.get_option('dim_suffix', True) script.save_config()
def __init__(self, xaml_file_name, reset_config=False): forms.WPFWindow.__init__(self, xaml_file_name) # verify keynote file existence self._kfile = revit.query.get_local_keynote_file(doc=revit.doc) self._kfile_handler = None if not self._kfile: self._kfile_ext = \ revit.query.get_external_keynote_file(doc=revit.doc) self._kfile_handler = 'unknown' # mak sure ADC is available if self._kfile_handler == 'unknown': if adc.is_available(): self._kfile_handler = 'adc' # check if keynote file is being synced by ADC # use the drive:// path for adc communications # adc module takes both remote or local paths, # but remote is faster lookup local_kfile = adc.get_local_path(self._kfile_ext) if local_kfile: # check is someone else has locked the file locked, owner = adc.is_locked(self._kfile_ext) if locked: forms.alert( "Keynote file is being modified and locked by " "{}. Please try again later".format(owner), exitscript=True) # force sync to get the latest contents adc.sync_file(self._kfile_ext) adc.lock_file(self._kfile_ext) # now that adc communication is done, # replace with local path self._kfile = local_kfile self.Title += ' (BIM360)' else: forms.alert("Can not get keynote file from {}".format( adc.ADC_NAME), exitscript=True) else: forms.alert( "This model is using a keynote file that seems to be " "managed by {long} ({short}). But {short} is not " "running, or is not installed. Please install/run the " "{short} and open the keynote manager again".format( long=adc.ADC_NAME, short=adc.ADC_SHORTNAME), exitscript=True) # byt this point we must have a local path to the keynote file if not self._kfile or not op.exists(self._kfile): self._kfile = None forms.alert("Keynote file is not accessible. " "Please select a keynote file.") self._change_kfile() # if a keynote file is still not set, return if not self._kfile: raise Exception('Keynote file is not setup.') # if a keynote file is still not set, return if not os.access(self._kfile, os.W_OK): raise Exception('Keynote file is read-only.') self._conn = None try: self._conn = kdb.connect(self._kfile) except System.TimeoutException as toutex: forms.alert(toutex.Message, expanded="{}::__init__()".format( self.__class__.__name__), exitscript=True) except Exception as ex: logger.debug('Connection failed | %s' % ex) res = forms.alert( "Existing keynote file needs to be converted to " "a format usable by this tool. The resulting keynote " "file is still readble by Revit and could be shared " "with other projects. Users should NOT be making changes to " "the existing keynote file during the conversion process.\n" "Are you sure you want to convert?", options=[ "Convert", "Select a different keynote file", "Give me more info" ]) if res: if res == "Convert": try: self._convert_existing() forms.alert("Conversion completed!") if not self._conn: forms.alert( "Launch the tool again to manage keynotes.", exitscript=True) except Exception as convex: logger.debug('Legacy conversion failed | %s' % convex) forms.alert("Conversion failed! %s" % convex, exitscript=True) elif res == "Select a different keynote file": self._change_kfile() elif res == "Give me more info": script.open_url(__helpurl__) #pylint: disable=undefined-variable script.exit() else: forms.alert("Keynote file is not yet converted.", exitscript=True) self._cache = [] self._allcat = kdb.RKeynote(key='', text='-- ALL CATEGORIES --', parent_key='', locked=False, owner='', children=None) self._needs_update = False self._config = script.get_config() self._used_keysdict = self.get_used_keynote_elements() self.load_config(reset_config) self.search_tb.Focus()
"""Activates selection tool that picks a specific type of element. Shift-Click: Pick favorites from all available categories """ # pylint: disable=E0401,W0703,C0103 from pyrevit import revit, DB from pyrevit import forms from pyrevit import script logger = script.get_logger() my_config = script.get_config("favourite_categories") # somehow DB.BuiltInCategory.OST_Truss does not have a corresponding DB.Category FREQUENTLY_SELECTED_CATEGORIES = [ DB.BuiltInCategory.OST_AreaSchemeLines, DB.BuiltInCategory.OST_Columns, DB.BuiltInCategory.OST_StructuralColumns, DB.BuiltInCategory.OST_Doors, DB.BuiltInCategory.OST_Floors, DB.BuiltInCategory.OST_StructuralFraming, DB.BuiltInCategory.OST_Walls, DB.BuiltInCategory.OST_Windows, ] class FSCategoryItem(forms.TemplateListItem): """Wrapper class for frequently selected category list item""" pass
def __init__(self, xaml_file_name): forms.WPFWindow.__init__(self, xaml_file_name) # verify keynote file existence self._kfile = revit.query.get_keynote_file(doc=revit.doc) if not self._kfile or not op.exists(self._kfile): self._kfile = None forms.alert("Keynote file is not accessible. " "Please select a keynote file.") self._change_kfile() # if a keynote file is still not set, return if not self._kfile: raise Exception('Keynote file is not setup.') self._conn = None try: self._conn = kdb.connect(self._kfile) except System.TimeoutException as toutex: forms.alert(toutex.Message, exitscript=True) except Exception as ex: logger.debug('Connection failed | %s' % ex) res = forms.alert( "Existing keynote file needs to be converted to " "a format usable by this tool. The resulting keynote " "file is still readble by Revit and could be shared " "with other projects. Users should NOT be making changes to " "the existing keynote file during the conversion process.\n" "Are you sure you want to convert?", options=["Convert", "Give me more info"]) if res: if res == "Convert": try: self._convert_existing() forms.alert("Conversion completed!") if not self._conn: forms.alert( "Launch the tool again to manage keynotes.", exitscript=True) except Exception as convex: logger.debug('Legacy conversion failed | %s' % convex) forms.alert("Conversion failed! %s" % convex, exitscript=True) elif res == "Give me more info": script.open_url('https://eirannejad.github.io/pyRevit') script.exit() else: forms.alert("Keynote file is not yet converted.", exitscript=True) self._cache = [] self._allcat = kdb.RKeynote(key='', text='-- ALL CATEGORIES --', parent_key='', locked=False, owner='', children=None) self._config = script.get_config() self._used_keys = self.get_used_keynote_elements().keys() self._update_window_geom() self._update_postable_commands() self._update_last_category() self.search_tb.Focus()