def create_pattern(self): fill_grids = [self._make_fill_grid(x) for x in self._pattern_grids] # Make new FillPattern fp_target = \ DB.FillPatternTarget.Model \ if self._model_pat else DB.FillPatternTarget.Drafting fill_pat = DB.FillPattern(self._name, fp_target, DB.FillPatternHostOrientation.ToHost) # Apply the FillGrids fill_pat.SetFillGrids(List[DB.FillGrid](fill_grids)) # Create the FillPatternElement in current document return self._make_fillpattern_element(fill_pat)
def make_pattern(patdef): logger.debug(patdef) # make the grids fill_grids = [] for pgrid in patdef.grids: pscale = MM_SCALE if patdef.units == 'MM' else INCH_SCALE logger.debug('scale is set to: {}'.format(pscale)) fgrid = make_fillgrid(pgrid, scale=pscale) if fgrid: fill_grids.append(fgrid) # determine pattern type fp_target = \ DB.FillPatternTarget.Model if patdef.type=='MODEL' \ else DB.FillPatternTarget.Drafting logger.debug('type is set to: {}'.format(fp_target)) # check if fillpattern element exists existing_fpelement = \ revit.query.get_fillpattern_element(patdef.name, fp_target) # make fillpattern rvt_fill_pat = DB.FillPattern(patdef.name, fp_target, DB.FillPatternHostOrientation.ToHost) rvt_fill_pat.SetFillGrids(framework.List[DB.FillGrid](fill_grids)) if existing_fpelement: existing_fpelement.SetFillPattern(rvt_fill_pat) logger.debug('Updated FillPatternElement with id:{}'.format( existing_fpelement.Id)) else: # make pattern element logger.debug('Creating new fillpattern element...') fill_pat_element = DB.FillPatternElement.Create( revit.doc, rvt_fill_pat) # log results logger.debug('Fill Pattern:{}'.format(fill_pat_element.Name)) fp = fill_pat_element.GetFillPattern() logger.debug('Fill Grids Count: {}'.format(len(fp.GetFillGrids()))) for idx, fg in enumerate(fp.GetFillGrids()): logger.debug( 'FillGrid #{} ' 'Origin:{} Angle:{} Shift:{} Offset:{} Segments:{}'.format( idx, fg.Origin, fg.Angle, fg.Shift, fg.Offset, fg.GetSegments()))