Пример #1
0
def ask_for_preflight_checks():
    """Ask user for preflight tests and run one by one"""
    # ask user for test case
    selected_check = forms.SelectFromList.show(
        preflight.get_all_preflight_checks(),
        title="Select Preflight Check",
        button_name="Run Check",
        multiselect=False,
        info_panel=True,
        checked_only=True,
        height=400,
        width=750,
        item_template=forms.utils.load_ctrl_template(
            script.get_bundle_file("PreflightCheckTemplate.xaml")
        ),
    )

    if selected_check:
        logger.debug("Running: {}".format(selected_check))
        preflight.run_preflight_check(
            selected_check, doc=revit.doc, output=output
        )
Пример #2
0
import sys
import os.path as op
import clr

from pyrevit import USER_SYS_TEMP
from pyrevit import script
from pyrevit.framework import IO

# compile
try:
    source = script.get_bundle_file('ipycompiletest.py')
    dest = op.join(USER_SYS_TEMP, 'compiledipytest.dll')
    clr.CompileModules(dest, source)
except IO.IOException as ioerr:
    print('DLL file already exists...')
except Exception as cerr:
    print('Compilation failed: {}'.format(cerr))

# import test
sys.path.append(USER_SYS_TEMP)
clr.AddReferenceToFileAndPath(dest)

import ipycompiletest

ipycompiletest.compile_test('Compiled function works.')

ipycompiletest.CompiledType('Compiled type works.')
Пример #3
0
"""Adjust all textnotes width in document by a multiplier
"""
__title__ = 'Adjust Text Note Width'
__author__= 'marentette'

from Autodesk.Revit.DB import \
FilteredElementCollector,TextNote

from june import revit_transaction 

#Import UI 
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('IronPython.Wpf')
from pyrevit import script
xamlfile = script.get_bundle_file('ui.xaml')
import wpf
from System import Windows

#Collect all textnotes in active document
doc = __revit__.ActiveUIDocument.Document
text_notes= FilteredElementCollector(doc).OfClass(TextNote).WhereElementIsNotElementType().ToElements() 

@revit_transaction('Set Width')
def set_text_width(elements,Multiplier):
    for e in elements:
        new_width = e.Width*Multiplier  
        if e.GetMaximumAllowedWidth() > new_width:
            e.Width = new_width 
        else: 
            e.Width = e.GetMaximumAllowedWidth()
Пример #4
0
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as ET

from pyrevit import script

__context__ = 'zerodoc'


utf8xml = script.get_bundle_file('utf8.xml')
utf16xml = script.get_bundle_file('utf16.xml')


for xmlfile in [utf8xml, utf16xml]:
    print('Testing: {}'.format(xmlfile))
    c = ET.parse(xmlfile)
    print(c)

    xmlp = ET.XMLParser(encoding="utf-16")
    f = ET.parse(xmlfile, parser=xmlp)
    print(xmlp, f)
Пример #5
0
__title__ = "Develop Credit"

import wpf

from System import Uri, UriKind
from System.Windows import Window
from System.Windows.Controls import Image
from System.Windows.Media.Imaging import BitmapImage
#find the path of ui.xaml
import pyrevit
from pyrevit import script
from pyrevit import UI

xamlfile = script.get_bundle_file('New_App_UI.xaml')


class MyWindow(Window):
    def __init__(self):
        wpf.LoadComponent(self, xamlfile)
        logo = Image()
        bi = BitmapImage()
        bi.BeginInit()
        bi.UriSource = Uri("/logo-portcoast.png", UriKind.Relative)
        bi.EndInit()
        logo.Source = bi


MyWindow().ShowDialog()
            return False

    def AllowReference(self, ref, point):
        return true


sel = [doc.GetElement(elid) for elid in uidoc.Selection.GetElementIds()]

t = Transaction(doc, 'Test')
t.Start()

clr.AddReference('System.Windows.Forms')
clr.AddReference('IronPython.Wpf')
from pyrevit import script

xamlfile = script.get_bundle_file('window.xaml')
import wpf
from System import Windows

# settings = {'var': 3}

import json

param = doc.ProjectInformation.LookupParameter('pyrevit').AsString()
settings = json.loads(param or '{}')

var = settings.get('var', 1)

if __shiftclick__:
    class MyWindow(Windows.Window):
        def __init__(self):
Пример #7
0
from pyrevit import forms
from pyrevit import revit, DB

#Defining our current Revit document as 'doc'
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

__doc__ = 'Manage worksets and pinning of critical elements and links.'\

# find the path of ui.xaml
from pyrevit import UI
from pyrevit import script

logger = script.get_logger()
xamlfile = script.get_bundle_file('AboutWindow.xaml')

# import WPF creator and base Window
import wpf
from System import Windows


class AboutWindow(Windows.Window):
    def __init__(self):
        wpf.LoadComponent(self, xamlfile)
        self.logo_img.Source = self._get_logo_image()

    #get logo png from root folder
    def _get_logo_image(self):
        path = os.path.dirname(os.path.abspath(__file__))
        logo = os.path.join(path, 'logo.png')
Пример #8
0
 def _read_resources(self):
     dt_template_file = script.get_bundle_file('PackagesDataTemplate.xaml')
     with open(dt_template_file, 'r') as dt_file:
         self.dt_template = dt_file.read()
Пример #9
0
# -*- coding: utf-8 -*-

# Ref
import clr
clr.AddReference("System")
clr.AddReference('System.Windows.Forms')
clr.AddReference('IronPython.Wpf')

from pyrevit import script
from pyrevit import UI
xamlfile = script.get_bundle_file('ui_rack.xaml')

from rpw import revit, db, ui, DB, UI
import wpf
from System import *
from System.Windows import *

import pickle
import os
from tempfile import gettempdir

uiapp = __revit__ 
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
doc = uidoc.Document

class RevitOperator():
    def __init__(self):
        #set default family type
        families = db.Collector(of_category="OST_GenericModel",is_type=True)
        types = []