Ejemplo n.º 1
0
    def _make_fill_grid(self, pattern_grid):
        fg_scale = self._scale

        fg_rotation = self._rotation
        if (self._flip_u and not self._flip_v) \
                or (self._flip_v and not self._flip_u):
            fg_rotation = -fg_rotation

        rvt_fill_grid = DB.FillGrid()

        # determine and set angle
        if self._flip_u and self._flip_v:
            rvt_fill_grid.Angle = PI + pattern_grid.angle
        elif self._flip_u:
            rvt_fill_grid.Angle = PI - pattern_grid.angle
        elif self._flip_v:
            rvt_fill_grid.Angle = -pattern_grid.angle
        else:
            rvt_fill_grid.Angle = pattern_grid.angle
        rvt_fill_grid.Angle += fg_rotation

        # determine and set origin
        # apply flips
        origin_u = -pattern_grid.origin.u if self._flip_u \
            else pattern_grid.origin.u
        origin_v = -pattern_grid.origin.v if self._flip_v \
            else pattern_grid.origin.v
        # apply rotation if any
        fg_origin = _PatternPoint(origin_u, origin_v)
        if fg_rotation:
            fg_origin.rotate(fg_rotation)
        rvt_fill_grid.Origin = \
            DB.UV(fg_origin.u * fg_scale, fg_origin.v * fg_scale)

        # determine and set offset
        if self._flip_u and self._flip_v:
            rvt_fill_grid.Offset = pattern_grid.offset * fg_scale
        elif self._flip_u or self._flip_v:
            rvt_fill_grid.Offset = -pattern_grid.offset * fg_scale
        else:
            rvt_fill_grid.Offset = pattern_grid.offset * fg_scale

        # determine and set shift
        rvt_fill_grid.Shift = pattern_grid.shift * fg_scale

        # build and set segments list
        if pattern_grid.segments:
            scaled_segments = \
                [seg * fg_scale for seg in pattern_grid.segments]
            rvt_fill_grid.SetSegments(scaled_segments)

        return rvt_fill_grid
Ejemplo n.º 2
0
    def get_rvt_fillgrid(self):
        rvt_fill_grid = DB.FillGrid()
        rvt_fill_grid.Origin = DB.UV(self.origin.u * self._scale,
                                     self.origin.v * self._scale)
        rvt_fill_grid.Angle = self.angle
        rvt_fill_grid.Offset = self.offset * self._scale
        rvt_fill_grid.Shift = self.shift * self._scale

        scaled_segments = [x * self._scale
                           for x in self._rvt_fillgrid.GetSegments()]
        rvt_fill_grid.SetSegments(scaled_segments)

        return rvt_fill_grid
Ejemplo n.º 3
0
def make_fillgrid(gridstring, scale=0.00328084):
    logger.debug(gridstring, scale)
    rvt_fill_grid = DB.FillGrid()
    griddata = [float(x.strip()) for x in gridstring.split(',') if x]
    if griddata:
        rvt_fill_grid.Angle = math.radians(griddata[0])
        rvt_fill_grid.Origin = \
            DB.UV(griddata[1] * scale, griddata[2] * scale)
        rvt_fill_grid.Shift = griddata[3] * scale
        rvt_fill_grid.Offset = griddata[4] * scale
        if len(griddata) > 5:
            scaled_segments = [abs(x) * scale for x in griddata[5:]]
            rvt_fill_grid.SetSegments(scaled_segments)

        return rvt_fill_grid
Ejemplo n.º 4
0
    def _make_fill_grid(self, pattern_grid):
        if isinstance(pattern_grid, _RevitFillGrid):
            rvt_fill_grid = pattern_grid.get_rvt_fillgrid()
        else:
            scale = self._scale
            rvt_fill_grid = DB.FillGrid()
            rvt_fill_grid.Angle = pattern_grid.angle
            rvt_fill_grid.Origin = \
                DB.UV(pattern_grid.origin.u * scale,
                      pattern_grid.origin.v * scale)
            rvt_fill_grid.Offset = pattern_grid.offset * scale
            rvt_fill_grid.Shift = pattern_grid.shift * scale
            if pattern_grid.segments:
                scaled_segments = [seg * scale for seg in pattern_grid.segments]
                rvt_fill_grid.SetSegments(scaled_segments)

        return rvt_fill_grid