def Execute(self, app): with Transaction(doc, "Разместить на лист") as t: t.Start() if Viewport.CanAddViewToSheet(doc, sheets[self.form.combo_box.SelectedItem], doc.ActiveView.Id): Viewport.Create(doc, sheets[self.form.combo_box.SelectedItem], doc.ActiveView.Id, XYZ(-1,1,0)) # message("Вид '{}'' размещен на лист '{}'".format(doc.ActiveView.Title, self.form.combo_box.SelectedItem)) else: message("Вид '{}'' не может быть добавлен на лист '{}'".format(doc.ActiveView.Title, self.form.combo_box.SelectedItem)) t.Commit()
def create_detail_section(assembly, orientation, sheet, point, vp_type_name=None, template=None, scale=5): section_view = AssemblyViewUtils.CreateDetailSection(doc, assembly.Id, orientation) section_view.Scale = scale vp_section_view = Viewport.Create(doc, sheet.Id, section_view.Id, point) if vp_type_name: change_type(vp_section_view, vp_type_name) if template: section_view.ViewTemplateId = select_template_id(template) return section_view, vp_section_view
for view in selected_views: #>>>>>>>>>> CREATE SHEET Sheet = ViewSheet.Create(doc, selected_title_block) #>>>>>>>>>> SET SHEET NUMBER count = "{:02d}".format(start_count) # 1 -> 01... sheet_number = prefix + count fail_count = 0 while True: fail_count += 1 if fail_count > 10: break try: Sheet.SheetNumber = sheet_number break except: sheet_number += "*" start_count += 1 #>>>>>>>>>> PLACE VIEW ON SHEET Viewport.Create(doc, Sheet.Id, view.Id, XYZ(0, 0, 0)) Sheet.Name = view.Name print('Created sheet: {} - {}'.format(sheet_number, Sheet.Name)) t.Commit()
uidoc.ActiveView = cursheet sel = uidoc.Selection.PickObjects(ObjectType.Element) for el in sel: selViewports.append(doc.GetElement(el)) if len(selViewports) > 0: with Transaction(doc, 'Move Viewports') as t: t.Start() for sht in selSheets: for vp in selViewports: if isinstance(vp, Viewport): viewId = vp.ViewId vpCenter = vp.GetBoxCenter() vpTypeId = vp.GetTypeId() cursheet.DeleteViewport(vp) nvp = Viewport.Create(doc, sht.Id, viewId, vpCenter) nvp.ChangeTypeId(vpTypeId) elif isinstance(vp, ScheduleSheetInstance): nvp = ScheduleSheetInstance.Create( doc, sht.Id, vp.ScheduleId, vp.Point) doc.Delete(vp.Id) t.Commit() else: TaskDialog.Show('pyRevit', 'At least one viewport must be selected.') elif len(selSheets) == 0: TaskDialog.Show( 'pyRevit', 'You must select at least one sheet to add the selected viewports to.') elif len(selSheets) > 2: TaskDialog.Show('pyRevit', 'Maximum of two sheets can only be selected.')
cursheet = uidoc.ActiveGraphicalView for v in selSheets: if cursheet.Id == v.Id: selSheets.remove(v) else: cursheet = selSheets[0] selSheets.remove(cursheet) uidoc.ActiveView = cursheet sel = uidoc.Selection.PickObjects(ObjectType.Element) for el in sel: selViewports.append(doc.GetElement(el)) if len(selViewports) > 0: with Transaction(doc, 'Add Viewports to Sheets') as t: t.Start() for sht in selSheets: for vp in selViewports: if isinstance(vp, Viewport): nvp = Viewport.Create(doc, sht.Id, vp.ViewId, vp.GetBoxCenter()) nvp.ChangeTypeId(vp.GetTypeId()) elif isinstance(vp, ScheduleSheetInstance): ScheduleSheetInstance.Create(doc, sht.Id, vp.ScheduleId, vp.Point) t.Commit() else: TaskDialog.Show('pyrevit', 'At least one viewport must be selected.') else: TaskDialog.Show('pyrevit', 'At least one sheet must be selected.')
ids = List[ElementId]() ids.Add(sel.ElementId) family = elem.Symbol.Family TransactionManager.Instance.EnsureInTransaction(doc) # Создание сборки assembly = AssemblyInstance.Create(doc, ids, elem.Category.Id) # Создание листа сборки assembly_sheet = AssemblyViewUtils.CreateSheet(doc, assembly.Id, get_title_block('ARH_TitleBlock')) assembly_sheet.Name = elem_name # Создание 3д вида view3D = create_View3D(assembly, 10) pt_view3d = XYZ(1.12578803139851, 0.250911809407337, 0) vp_view3d = Viewport.Create(doc, assembly_sheet.Id, view3D.Id, pt_view3d) change_type(vp_view3d, 'ARH_БезЗаголовка') # Создание спецификации view_schedule = create_schedule(assembly) view_schedule.ViewTemplateId = select_template_id('ARH_Detail_Template') vp_schedule = ScheduleSheetInstance.Create(doc, assembly_sheet.Id, view_schedule.Id, XYZ.Zero) doc.Regenerate() move_element_schedule(vp_schedule, assembly_sheet, 415, 292) # Создание разреза pt_section_view = XYZ(1.10604515064852, 0.626337804965914, 0) section_view = create_detail_section(assembly, AssemblyDetailViewOrientation.DetailSectionB, assembly_sheet, pt_section_view,