Exemplo n.º 1
0
def create_dest_view(view_type, view_name, view_scale):
    with Transaction(doc, 'Create model view') as t:
        t.Start()
        try:
            dest_view = None
            if view_type == 'Floor Plan':
                level = get_view_level()
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeFloorPlan)
                dest_view = ViewPlan.Create(doc, view_fam_typeid, level.Id)
            elif view_type == 'Reflected Ceiling Plan':
                level = get_view_level()
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeCeilingPlan)
                dest_view = ViewPlan.Create(doc, view_fam_typeid, level.Id)
            elif view_type == 'Section':
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeSection)
                view_direction = BoundingBoxXYZ()
                trans_identity = Transform.Identity
                trans_identity.BasisX = -XYZ.BasisX  # x direction
                trans_identity.BasisY = XYZ.BasisZ  # up direction
                trans_identity.BasisZ = XYZ.BasisY  # view direction
                view_direction.Transform = trans_identity
                dest_view = ViewSection.CreateSection(doc, view_fam_typeid,
                                                      view_direction)
                scale_param = dest_view.LookupParameter(
                    'Hide at scales coarser than')
                scale_param.Set(1)
            elif view_type == 'Elevation':
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeElevation)
                elev_marker = ElevationMarker.CreateElevationMarker(
                    doc, view_fam_typeid, XYZ(0, 0, 0), 1)
                default_floor_plan = find_first_floorplan()
                dest_view = elev_marker.CreateElevation(
                    doc, default_floor_plan.Id, 0)
                scale_param = dest_view.LookupParameter(
                    'Hide at scales coarser than')
                scale_param.Set(1)

            dest_view.ViewName = view_name
            dest_view.Scale = view_scale
            model_visib_param = dest_view.LookupParameter('Display Model')
            model_visib_param.Set(2)
            dest_view.CropBoxActive = False
            dest_view.CropBoxVisible = False
            t.Commit()
            return dest_view
        except Exception as create_err:
            t.RollBack()
            logger.debug('Can not create model view: {} | {}'.format(
                view_name, create_err))
            raise create_err
Exemplo n.º 2
0
def create_dest_view(view_type, view_name, view_scale):
    with Transaction(doc, 'Create model view') as t:
        t.Start()
        try:
            dest_view = None
            if view_type == 'Floor Plan':
                level = get_view_level()
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeFloorPlan)
                dest_view = ViewPlan.Create(doc, view_fam_typeid, level.Id)
            elif view_type == 'Reflected Ceiling Plan':
                level = get_view_level()
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeCeilingPlan)
                dest_view = ViewPlan.Create(doc, view_fam_typeid, level.Id)
            elif view_type == 'Section':
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeSection)
                view_direction = BoundingBoxXYZ()
                trans_identity = Transform.Identity
                trans_identity.BasisX = -XYZ.BasisX  # x direction
                trans_identity.BasisY = XYZ.BasisZ  # up direction
                trans_identity.BasisZ = XYZ.BasisY  # view direction
                view_direction.Transform = trans_identity
                dest_view = ViewSection.CreateSection(doc, view_fam_typeid,
                                                      view_direction)
                scale_param = dest_view.Parameter[
                    DB.BuiltInParameter.
                    SECTION_COARSER_SCALE_PULLDOWN_IMPERIAL]
                scale_param.Set(1)
            elif view_type == 'Elevation':
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeElevation)
                elev_marker = ElevationMarker.CreateElevationMarker(
                    doc, view_fam_typeid, XYZ(0, 0, 0), 1)
                default_floor_plan = find_first_floorplan()
                dest_view = elev_marker.CreateElevation(
                    doc, default_floor_plan.Id, 0)
                scale_param = dest_view.Parameter[
                    DB.BuiltInParameter.
                    SECTION_COARSER_SCALE_PULLDOWN_IMPERIAL]
                scale_param.Set(1)
            elif view_type == 'Drafting':
                view_fam_typeid = doc.GetDefaultElementTypeId(
                    ElementTypeGroup.ViewTypeDrafting)
                dest_view = ViewDrafting.Create(doc, view_fam_typeid)

            dest_view.ViewName = view_name
            dest_view.Scale = view_scale
            model_visib_param = dest_view.Parameter[
                DB.BuiltInParameter.VIEW_MODEL_DISPLAY_MODE]
            if model_visib_param:
                model_visib_param.Set(2)
            dest_view.CropBoxActive = False
            dest_view.CropBoxVisible = False
            t.Commit()
            return dest_view
        except Exception as create_err:
            t.RollBack()
            logger.debug('Can not create model view: {} | {}'.format(
                view_name, create_err))
            raise create_err
Exemplo n.º 3
0
        if p.X > q.X or (p.X == q.X and p.Y < q.Y): fc = 1
        else: fc = -1

        midpoint = p + 0.5 * v
        walldir = fc * v.Normalize()
        up = XYZ.BasisZ
        viewdir = walldir.CrossProduct(up)

        t = Transform.Identity
        t.Origin = midpoint
        t.BasisX = walldir
        t.BasisY = up
        t.BasisZ = viewdir

        sectionBox = BoundingBoxXYZ()
        sectionBox.Transform = t
        sectionBox.Min = min  # scope box bottom
        sectionBox.Max = max  # scope box top

        with db.Transaction('Create Section'):
            # Create wall section view
            newSection = ViewSection.CreateSection(doc, viewFamilyTypeId,
                                                   sectionBox)
            newSections.append(newSection)
else:
    newSections = []
    for wall in walls:
        # Determine section box
        lc = wall.Location
        line = lc.Curve
Exemplo n.º 4
0
    curve_transform = curve.ComputeDerivatives(0.5, True)

    origin = curve_transform.Origin
    wall_direction = curve_transform.BasisX.Normalize()  # type: XYZ
    up = XYZ.BasisZ
    section_direction = wall_direction.CrossProduct(up)
    right = up.CrossProduct(section_direction)

    transform = Transform.Identity
    transform.Origin = origin
    transform.BasisX = wall_direction
    transform.BasisY = up
    transform.BasisZ = section_direction

    section_box = BoundingBoxXYZ()
    section_box.Transform = transform

    # Try to retrieve element height, width and lenght
    try:
        el_depth =  element.WallType.Width
    except AttributeError:
        el_depth = 2

    el_width = curve.Length

    el_bounding_box = element.get_BoundingBox(None)
    z_min = el_bounding_box.Min.Z
    z_max = el_bounding_box.Max.Z
    el_height = z_max - z_min

   # Get Wall Offset Params if Element is Wall