//
// (C) Copyright 2003-2007 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
namespace Revit.SDK.Samples.CreateComplexAreaRein.CS
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using Autodesk.Revit;
using Autodesk.Revit.Parameters;
using Autodesk.Revit.Elements;
using Autodesk.Revit.Geometry;
using Autodesk.Revit.Symbols;
using GeoElement = Autodesk.Revit.Geometry.Element;
//using GeoSolid = Autodesk.Revit.Geometry.Solid; // jeremy
using Element = Autodesk.Revit.Element;
///
/// data and data manager of the AreaReinforcement
///
public class AreaReinData
{
///
/// constructor, initialize member data
///
public AreaReinData()
{
m_areaReinTypes = new List();
}
private List m_areaReinTypes;
private LayoutRules m_layoutRule = LayoutRules.Maximum_Spacing;
private object m_areaReinType;
///
/// all the AreaReinforcementTypes in the current project
///
public List AreaReinTypes
{
get
{
return m_areaReinTypes;
}
set
{
m_areaReinTypes = value;
}
}
///
/// user selected AreaReinforcementType when create
///
public object AreaReinType
{
get
{
return m_areaReinType;
}
set
{
m_areaReinType = value;
}
}
///
/// Parameter LayoutRule of AreaReinforcement
///
public LayoutRules LayoutRule
{
get
{
return m_layoutRule;
}
set
{
m_layoutRule = value;
}
}
///
/// set the parameters to given AreaReinforcement
///
///
public virtual void FillIn(AreaReinforcement areaRein)
{
int temp = (int)m_layoutRule;
bool flag = ParameterUtil.SetParaInt(areaRein,
BuiltInParameter.REBAR_SYSTEM_LAYOUT_RULE, temp);
//if BuiltInParameter doesn't work
if(!flag)
{
Parameter paraLayout = ParameterUtil.FindParaByName(
areaRein.Parameters, "Layout Rule");
if (null != paraLayout)
{
paraLayout.Set(temp);
}
}
ChangeAreaReinCurves(areaRein);
}
///
/// On the interior 4 curves, set the override flag
/// and flip the hooks on the top 2 layers to ˇ°upˇ±
///
///
private void ChangeAreaReinCurves(AreaReinforcement areaRein)
{
//interior 4 curves are listed in the back of the curves,
//this order is decided when we create it
for (int i = 4; i < 8; i++)
{
AreaReinforcementCurve areaReinCurve =
areaRein.Curves.get_Item(i) as AreaReinforcementCurve;
//remove hooks, set the hook the top 2 layers to 'up'
ParameterUtil.SetParaInt(areaReinCurve,
BuiltInParameter.REBAR_SYSTEM_OVERRIDE, -1);
ParameterUtil.SetParaInt(areaReinCurve,
BuiltInParameter.REBAR_SYSTEM_HOOK_ORIENT_TOP_DIR_1,
(int)HookOrientation.Up);
ParameterUtil.SetParaInt(areaReinCurve,
BuiltInParameter.REBAR_SYSTEM_HOOK_ORIENT_TOP_DIR_2,
(int)HookOrientation.Up);
}
}
}
}