예제 #1
0
        public void ByNameNumberTitleBlockViewsAndLocations_ValidArgs()
        {
            ElementBinder.IsEnabled = false;

            var famSymName = "E1 30x42 Horizontal";
            var famName    = "E1 30 x 42 Horizontal";
            var titleBlock = FamilyType.ByFamilyAndName(Family.ByName(famName), famSymName);

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var pt2      = Point.ByCoordinates(100, 100, 0);
            var famInst2 = FamilyInstance.ByPoint(famTyp, pt2);

            var view  = SectionView.ByBoundingBox(famInst.BoundingBox);
            var view2 = SectionView.ByBoundingBox(famInst2.BoundingBox);

            var location  = Point.ByCoordinates(0, 0, 0);
            var location2 = Point.ByCoordinates(0, 1, 0);

            var sheetName   = "Poodle";
            var sheetNumber = "A1";

            var ele = Sheet.ByNameNumberTitleBlockViewsAndLocations(sheetName, sheetNumber, titleBlock, new[] { view, view2 }, new[] { location, location2 });

            Assert.NotNull(ele);
        }
        //Get the parameter value as Double
        private static double GetParameterValue(FamilyType ft, FamilyParameter fp)
        {
            double value = 0.0;

            switch (fp.StorageType)
            {
            case (StorageType.Double):
                value = Convert.ToDouble(ft.AsDouble(fp));
                break;

            case (StorageType.Integer):
                value = Convert.ToDouble(ft.AsInteger(fp));
                break;

            case (StorageType.String):
                value = 0.0;
                break;

            case (StorageType.ElementId):
                value = 0.0;
                break;

            default:
                break;
            }

            return(value);
        }
예제 #3
0
        public void ByNameNumberTitleBlockAndViews_BadArgs()
        {
            ElementBinder.IsEnabled = false;

            var famSymName = "E1 30x42 Horizontal";
            var famName    = "E1 30 x 42 Horizontal";
            var titleBlock = FamilyType.ByFamilyAndName(Family.ByName(famName), famSymName);

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var pt2      = Point.ByCoordinates(100, 100, 0);
            var famInst2 = FamilyInstance.ByPoint(famTyp, pt2);

            var view  = SectionView.ByBoundingBox(famInst.BoundingBox);
            var view2 = SectionView.ByBoundingBox(famInst2.BoundingBox);

            var sheetName   = "Poodle";
            var sheetNumber = "A1";

            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(null, sheetNumber, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, null, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, null, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, titleBlock, null));
        }
예제 #4
0
        public static string FamilyParamValueString(FamilyType t, FamilyParameter fp, Document doc)
        {
            string value = t.AsValueString(fp);

            switch (fp.StorageType)
            {
            case StorageType.Double:
                value = t.AsValueString(fp);
                break;

            /* case StorageType.ElementId:
             *   ElementId id = t.AsElementId(fp);
             *   Element e = doc.GetElement(id);
             *   value = id.IntegerValue.ToString() + " (" + e.Name + ")";
             *   break;*/

            case StorageType.Integer:
                value = t.AsInteger(fp).ToString();
                break;

            case StorageType.String:
                value = t.AsString(fp);
                break;
            }
            return(value);
        }
예제 #5
0
        /// <summary>
        /// Converts the MultiPoint into an adaptive component of the specified type.
        /// </summary>
        /// <param name="familyType">Type of the family.</param>
        /// <returns></returns>
        public AdaptiveComponent ToAdaptiveComponent(FamilyType familyType)
        {
            Utils.Log(string.Format("MultiPoint.ToAdaptiveComponent started...", ""));

            AdaptiveComponent output = null;

            try
            {
                if (!SessionVariables.ParametersCreated)
                {
                    UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
                }

                output = AdaptiveComponent.ByPoints(new Point[][] { this.ShapePoints.Points.Select(p => p.RevitPoint).ToArray() }, familyType)[0];
                output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, this.SerializeJSON());
                output.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1);
                output.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0);
            }
            catch (Exception ex)
            {
                Utils.Log(ex.Message);
            }

            Utils.Log(string.Format("MultiPoint.ToAdaptiveComponent completed.", ""));

            return(output);
        }
예제 #6
0
        public static bool CheckID(this Document doc)
        {
            string v = string.Empty;

            if (doc.IsFamilyDocument)
            {
                if (doc.FamilyManager.get_Parameter(ProjectParams.CC_ID.Guid) != null)
                {
                    FamilyParameter p = doc.FamilyManager.get_Parameter(ProjectParams.CC_ID.Guid);
                    FamilyType      t = doc.FamilyManager.CurrentType;
                    try { v = t.AsString(p); } catch { }
                }
            }
            else
            {
                if (doc.ProjectInformation.get_Parameter(ProjectParams.CC_ID.Guid) != null)
                {
                    Parameter p = doc.ProjectInformation.get_Parameter(ProjectParams.CC_ID.Guid);
                    try { v = p.AsString(); } catch { }
                }
            }
            if (v == string.Empty)
            {
                return(false);
            }
            if (v == null)
            {
                return(false);
            }
            if (v.Length < 30)
            {
                return(false);
            }
            return(true);
        }
        static string FamilyParamValueString(
            FamilyType t,
            FamilyParameter fp,
            Document doc)
        {
            string value = t.AsValueString(fp);

            switch (fp.StorageType)
            {
            case StorageType.Double:
                value = Util.RealString(
                    (double)t.AsDouble(fp))
                        + " (double)";
                break;

            case StorageType.ElementId:
                ElementId id = t.AsElementId(fp);
                Element   e  = doc.GetElement(id);
                value = id.IntegerValue.ToString() + " ("
                        + Util.ElementDescription(e) + ")";
                break;

            case StorageType.Integer:
                value = t.AsInteger(fp).ToString()
                        + " (int)";
                break;

            case StorageType.String:
                value = "'" + t.AsString(fp)
                        + "' (string)";
                break;
            }
            return(value);
        }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("IdFamilyType,NameFamilyType")] FamilyType familyType)
        {
            if (id != familyType.IdFamilyType)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(familyType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FamilyTypeExists(familyType.IdFamilyType))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(familyType));
        }
        /// <summary>
        /// Creates default family type.
        /// </summary>
        /// <param name="familyManager">The family manager.</param>
        /// <returns></returns>
        /// <exception cref="Exception">Aborted by user.</exception>
        private FamilyType CreateDefaultFamilyType(FamilyManager familyManager)
        {
            FamilyType familyType = null;

            TaskDialog td = new TaskDialog("No Family Type");

            td.MainInstruction = "Create Default Family Type.";
            string s = "This might be a new Family with no existing Parameters or Family Types." + Environment.NewLine + Environment.NewLine +
                       "In order to use this plugin, you can either create a new Parameter/Family Type from the Family Types Dialog" +
                       " and restart the plugin or create a Default Family Type by accepting this message." + Environment.NewLine + Environment.NewLine +
                       "You can always delete the Default Family Parameter later.";

            td.MainContent   = s;
            td.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;

            TaskDialogResult tResult = td.Show();

            if (TaskDialogResult.Yes == tResult)
            {
                using (Transaction t = new Transaction(doc, "Create Family Type"))
                {
                    t.Start();
                    familyType = familyManager.NewType("Default");
                    t.Commit();
                }
            }
            else
            {
                throw new Exception("Aborted by user.");
            }

            return(familyType);
        }
예제 #10
0
        /// <summary>
        /// Renumbers the views on the Active Sheet
        /// </summary>
        /// <param name="familyType">Dynamo FamilyType that represents the origin element</param>
        /// <param name="xGridName">Name of the parameter that represents the X grid spacing</param>
        /// <param name="yGridName">Name of the parameter that represents the Y grid spacing</param>
        /// <returns name="Viewports">Revit viewport objects on the sheet.</returns>
        public static List <revitViewport> RenumberOnActiveSheet(FamilyType familyType, string xGridName, string yGridName)
        {
            revitDoc   document = Document.Current();
            revitSheet rSheet   = (revitSheet)document.ActiveView;

            return(_renumberViewsOnSheet(familyType, xGridName, yGridName, rSheet, document));
        }
예제 #11
0
        /// <summary>
        /// Renumbers the views on the Active Sheet
        /// </summary>
        /// <param name="sheet">A dynamo Sheet element</param>
        /// <param name="familyType">Dynamo FamilyType that represents the origin element</param>
        /// <param name="xGridName">Name of the parameter that represents the X grid spacing</param>
        /// <param name="yGridName">Name of the parameter that represents the Y grid spacing</param>
        /// <returns name="Viewports">Revit viewport objects on the sheet.</returns>
        public static List <revitViewport> RenumberOnSheet(dynaSheet sheet, FamilyType familyType, string xGridName, string yGridName)
        {
            revitSheet rSheet   = (revitSheet)sheet.InternalElement;
            revitDoc   document = rSheet.Document;

            return(_renumberViewsOnSheet(familyType, xGridName, yGridName, rSheet, document));
        }
        // add one type (version 1)
        //
        void addType(string name, double w, double d)
        {
            // get the family manager from the current doc
              FamilyManager pFamilyMgr = _doc.FamilyManager;

              // add new types with the given name
              //
              FamilyType type1 = pFamilyMgr.NewType(name);

              // look for 'Width' and 'Depth' parameters and set them to the given value
              //
              // first 'Width'
              //
              FamilyParameter paramW = pFamilyMgr.get_Parameter("Width");
              double valW = mmToFeet(w);
              if (paramW != null)
              {
            pFamilyMgr.Set(paramW, valW);
              }

              // same idea for 'Depth'
              //
              FamilyParameter paramD = pFamilyMgr.get_Parameter("Depth");
              double valD = mmToFeet(d);
              if (paramD != null)
              {
            pFamilyMgr.Set(paramD, valD);
              }
        }
        /// <summary>
        /// the method is used to create new family type
        /// </summary>
        /// <param name="para">WindowParameter</param>
        /// <returns>indicate whether the NewType is successful</returns>
        private bool newFamilyType(WindowParameter para)//string typeName, double height, double width, double sillHeight)
        {
            DoubleHungWinPara dbhungPara  = para as DoubleHungWinPara;
            string            typeName    = dbhungPara.Type;
            double            height      = dbhungPara.Height;
            double            width       = dbhungPara.Width;
            double            sillHeight  = dbhungPara.SillHeight;
            double            windowInset = dbhungPara.Inset;

            switch (m_document.DisplayUnitSystem)
            {
            case Autodesk.Revit.DB.DisplayUnit.METRIC:
                height      = Utility.MetricToImperial(height);
                width       = Utility.MetricToImperial(width);
                sillHeight  = Utility.MetricToImperial(sillHeight);
                windowInset = Utility.MetricToImperial(windowInset);
                break;
            }
            try
            {
                FamilyType type = m_familyManager.NewType(typeName);
                m_familyManager.CurrentType = type;
                m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT), height);
                m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH), width);
                m_familyManager.Set(m_familyManager.get_Parameter("Default Sill Height"), sillHeight);
                m_familyManager.Set(m_familyManager.get_Parameter("Window Inset"), windowInset);
                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(false);
            }
        }
예제 #14
0
        public void ByFamilyAndName_BadArgs()
        {
            var fam = Family.ByName("Box");

            Assert.Throws(typeof(Exception), () => FamilyType.ByFamilyAndName(fam, "Turtle"));
            Assert.Throws(typeof(System.ArgumentNullException), () => FamilyType.ByFamilyAndName(fam, null));
            Assert.Throws(typeof(System.ArgumentNullException), () => FamilyType.ByFamilyAndName(null, "Turtle"));
        }
예제 #15
0
        public void ByName_GoodArgs()
        {
            var famTyp = FamilyType.ByName("Box");

            Assert.NotNull(famTyp);
            Assert.AreEqual("Box", famTyp.Name);
            Assert.AreEqual("Box", famTyp.Family.Name);
        }
예제 #16
0
 public bool BothParentsAlive(FactDate when)
 {
     if (Husband is null || Wife is null || FamilyType.Equals(SOLOINDIVIDUAL))
     {
         return(false);
     }
     return(Husband.IsAlive(when) && Wife.IsAlive(when) && Husband.GetAge(when).MinAge > 13 && Wife.GetAge(when).MinAge > 13);
 }
예제 #17
0
 /// <summary>Parse an AttributeAddress.</summary>
 public AttributeAddress(AttributeType type, MemBlock data) :
     base(type, data)
 {
     Family = (FamilyType)data[1];
     Port   = (ushort)NumberSerializer.ReadShort(data, 2);
     byte[] addr = new byte[data.Length - 4];
     data.Slice(4).CopyTo(addr, 0);
     IP = new IPAddress(addr);
 }
예제 #18
0
 internal FloorBorderProperties(
     FloorProperties floorProperties,
     FamilyType borderType,
     Level level)
 {
     FloorProperties = floorProperties;
     BorderType      = borderType;
     Level           = level;
 }
예제 #19
0
        internal static List <revitViewport> _renumberViewsOnSheet(FamilyType familyType, string xGridName, string yGridName, revitSheet rSheet, revitDoc document)
        {
            string transactionName = "Renumber views on sheet";

            //  Initialize variables
            revitFamilySymbol rFamilySymbol = (revitFamilySymbol)familyType.InternalElement;

            //  Get all viewport ID's on the sheet.
            List <revitElemId>   viewportIds = (List <revitElemId>)rSheet.GetAllViewports();
            List <revitViewport> viewports   = null;

            //  Get the family Instances in view
            revitElemId symbolId = familyType.InternalElement.Id;

            revitCollector     collector      = new revitCollector(document, rSheet.Id);
            revitElementFilter filterInstance = new revitDB.FamilyInstanceFilter(document, symbolId);

            collector.OfClass(typeof(revitDB.FamilyInstance)).WherePasses(filterInstance);

            revitDB.FamilyInstance originFamily = (revitDB.FamilyInstance)collector.FirstElement();

            //  If family instance is found in the view
            //  Then renumber views.
            if (originFamily != null)
            {
                revitDB.LocationPoint location = (revitDB.LocationPoint)originFamily.Location;
                revitXYZ originPoint           = location.Point;

                double gridX = rFamilySymbol.LookupParameter(xGridName).AsDouble();
                double gridY = rFamilySymbol.LookupParameter(yGridName).AsDouble();

                //  If the document is modifieable,
                //  then a transaction is already open
                //  and function uses the Dynamo Transaction Manager.
                //  Else, open a new transaction.
                if (document.IsModifiable)
                {
                    TransactionManager.Instance.EnsureInTransaction(document);
                    viewports = View._tempRenumberViewports(viewportIds, document);
                    viewports = View._renumberViewports(viewports, gridX, gridY, originPoint.X, originPoint.Y);
                    TransactionManager.Instance.TransactionTaskDone();
                }
                else
                {
                    using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document))
                    {
                        trans.Start(transactionName);
                        viewports = View._tempRenumberViewports(viewportIds, document);
                        viewports = View._renumberViewports(viewports, gridX, gridY, originPoint.X, originPoint.Y);
                        trans.Commit();
                    }
                }
            }

            return(viewports);
        }
        public FamilyTypeWrapper(FamilyType familyType, Document doc)
        {
            _familyType = familyType;
            _doc        = doc;

            // Типоразмер \"{familyType.Name}\"
            Title       = string.Format(Language.GetItem(ModPlusConnector.Instance.Name, "p5"), familyType.Name);
            Source      = familyType.Name;
            Destination = string.Empty;
        }
예제 #21
0
 public static FloorBorderProperties ByData(
     FloorProperties floorProperties,
     FamilyType borderType,
     Level level)
 {
     return(new FloorBorderProperties(
                floorProperties,
                borderType,
                level));
 }
예제 #22
0
        public static string ParameterToString(Document doc, FamilyParameter param, FamilyType type)
        {
            if (!type.HasValue(param))
            {
                return("无");
            }
            if (param.Definition.ParameterType == ParameterType.Invalid)
            {
                return("不可用");
            }
            switch (param.StorageType)
            {
            case StorageType.Double:
#if R2014
                var uStr = FormatUtils.Format(doc, param.Definition.UnitType, type.AsDouble(param).Value);
#else
                var uStr = UnitFormatUtils.Format(doc.GetUnits(), param.Definition.UnitType, type.AsDouble(param).Value, false, false);
#endif
                return(uStr);

            //var uStr = string.Empty;
            //if (param.Definition.ParameterType == ParameterType.Length)
            //{
            //    uStr = GetParamaterUnit(param.DisplayUnitType);
            //}
            //var dStr = param.AsValueString();
            //if (!String.IsNullOrEmpty(uStr) && !dStr.EndsWith(uStr)) dStr += uStr;
            //return dStr;
            case StorageType.Integer:
                var v = type.AsInteger(param).Value;
                if (param.Definition.ParameterType == ParameterType.YesNo)
                {
                    if (v == 0)
                    {
                        return("否");
                    }
                    return("是");
                }
#if R2014
                return(FormatUtils.Format(doc, param.Definition.UnitType, v));
#else
                return(UnitFormatUtils.Format(doc.GetUnits(), param.Definition.UnitType, v, false, false));
#endif
            case StorageType.String:
                return(type.AsString(param));

            case StorageType.ElementId:
                ElementId idVal = type.AsElementId(param);
                return(AsElementName(doc, idVal));

            case StorageType.None:
            default:
                return("无");
            }
        }
예제 #23
0
        public async Task <IActionResult> Create([Bind("IdFamilyType,NameFamilyType")] FamilyType familyType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(familyType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(familyType));
        }
예제 #24
0
 public ByLineInstanceProperties(
     Point p1,
     Point p2,
     FamilyType type,
     Level level)
 {
     P1    = p1;
     P2    = p2;
     Type  = type;
     Level = level;
 }
예제 #25
0
        public FamilyType RawFindFamilyType(FamilyManager fm, string familyTypeName)
        {
            FamilyType famType = RawConvertSetToList <FamilyType>(fm.Types).
                                 FirstOrDefault(e => e.Name.Equals(familyTypeName, StringComparison.CurrentCultureIgnoreCase));

            if (famType == null)
            {
                throw new Exception("Invalid FamilyTypeName Input!");
            }

            return(famType);
        }
예제 #26
0
        /// <summary>
        /// New Family Instance by Curve
        /// </summary>
        /// <param name="familyType">Family Type to be applied to new Family Instance.</param>
        /// <param name="line">Line to place Family Instance at.</param>
        /// <param name="level">Level to associate Family Instance with.</param>
        /// <returns>New Family Instance.</returns>
        public static Element ByLine(FamilyType familyType, Line line, Level level)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException(nameof(familyType));
            }

            var symbol       = familyType.InternalElement as Autodesk.Revit.DB.FamilySymbol;
            var locationLine = line.ToRevitType() as Autodesk.Revit.DB.Line;
            var hostLevel    = level.InternalElement as Autodesk.Revit.DB.Level;

            return(new FamilyInstances(symbol, locationLine, hostLevel));
        }
 public ByPointInstanceProperties(
     double length,
     double width,
     FamilyType type,
     Point position,
     double rotation)
 {
     Length   = length;
     Width    = width;
     Type     = type;
     Position = position;
     Rotation = rotation;
 }
예제 #28
0
        public void ByEyePointTargetAndElement_BadArgs()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            Assert.Throws(typeof(ArgumentNullException), () => AxonometricView.ByEyePointTargetAndElement(null, target, name, famInst, false));
            Assert.Throws(typeof(ArgumentNullException), () => AxonometricView.ByEyePointTargetAndElement(eye, null, name, famInst, false));
        }
예제 #29
0
        public void ByBoundingBox_ValidArgs()
        {
            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var view = SectionView.ByBoundingBox(famInst.BoundingBox);

            Assert.NotNull(view);

            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(view.InternalElement.UniqueId)));
        }
 public static IEnumerable <ByPointInstanceProperties> CreateList(
     List <double> lengths,
     List <double> widths,
     FamilyType type,
     List <FS_Vector3> positions,
     double rotation)
 {
     for (int i = 0; i < positions.Count; i++)
     {
         yield return(new ByPointInstanceProperties(
                          lengths[i], widths[i], type,
                          Point.ByCoordinates(positions[i].X, positions[i].Y, positions[i].Z), rotation));
     }
 }
예제 #31
0
 /// <summary>
 /// Check parameter conditions
 /// </summary>
 /// <param name="fp"></param>
 /// <param name="ft"></param>
 /// <returns></returns>
 private Boolean famEdit(FamilyParameter fp, FamilyType ft)
 {
     //double valueDouble;
     //int valueInt;
     if (!fp.StorageType.ToString().Equals("Double") && !fp.StorageType.ToString().Equals("Integer"))
     {
         return false;
     }
     else if (fp.UserModifiable)
     {
         return false;
     }
     else if (fp.IsDeterminedByFormula || fp.Formula != null)
     {
         return false;
     }
     else if (!ft.HasValue(fp))
     {
         return false;
     }
     else if (ft.AsDouble(fp) == null && ft.AsInteger(fp) == null)
     {
         return false;
     }
     //else if (!double.TryParse(ft.AsDouble(fp).ToString(), out valueDouble) && !int.TryParse(ft.AsInteger(fp).ToString(), out valueInt))
     //{
     //    return false;
     //}
     else if (fp.IsReporting)
     {
         return false;
     }
     else if (fp.IsDeterminedByFormula)
     {
         return false;
     }
     return true;
 }
예제 #32
0
 private void SetFormula(Document familyDoc)
 {
     _type = familyDoc.FamilyManager.NewType(_name);
     familyDoc.FamilyManager.AddParameter("Area", BuiltInParameterGroup.PG_CONSTRAINTS, ParameterType.Area, true); // need to add value
     FamilyParameter param = familyDoc.FamilyManager.get_Parameter("Area");
     if (null != param)
     {
         familyDoc.FamilyManager.Set(param, _area);
     }
     param = familyDoc.FamilyManager.get_Parameter("Height");
     if (null != param)
     {
         familyDoc.FamilyManager.SetFormula(param, @"Area / Width");
     }
 }
예제 #33
0
파일: Stun.cs 프로젝트: reith2004/ipop
 /// <summary>Parse an AttributeAddress.</summary>
 public AttributeAddress(AttributeType type, MemBlock data)
     : base(type, data)
 {
     Family = (FamilyType) data[1];
     Port = (ushort) NumberSerializer.ReadShort(data, 2);
     byte[] addr = new byte[data.Length - 4];
     data.Slice(4).CopyTo(addr, 0);
     IP = new IPAddress(addr);
 }
예제 #34
0
파일: Stun.cs 프로젝트: reith2004/ipop
            /// <summary>Create an AttributeAddress.</summary>
            public AttributeAddress(AttributeType type, IPAddress ip, ushort port)
                : base(type, CreateAddressData(ip, port))
            {
                if(ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
                  Family = FamilyType.IPv4;
                } else {
                  Family = FamilyType.IPv6;
                }

                IP = ip;
                Port = port;
            }
예제 #35
0
 public List<Parameter> GetRevitFamilyParameters(FamilyType type)
 {
     if (Document == null)
         throw new NullReferenceException("Autodesk Document is null: Must Get File before Getting Types");
     return (from FamilyParameter param in Document.FamilyManager.Parameters
             where ParamSwitch(param, type) != null
             let searchName = new SearchName {Name = param.Definition.Name}
             let searchValue = new SearchValue {Value = ParamSwitch(param, type).ToString()}
             select new Parameter {SearchValue = searchValue, SearchName = searchName}).ToList();
 }
예제 #36
0
 private Item IndexRevitMultipleTypes(FamilyType type)
 {
     return IndexRevitType(type);
 }
예제 #37
0
 private Item IndexRevitSingleType(FamilyType type)
 {
     return IndexRevitType(type, "Standard");
 }
예제 #38
0
 private Item IndexRevitType(FamilyType type, string nameOverride = "")
 {
     var currentItem = new Item
                           {
                               Name = type.Name.Trim() != String.Empty ? type.Name : nameOverride,
                               TypeCatalogEntry = string.Empty,
                               Parameters = GetRevitFamilyParameters(type)
                           };
     return currentItem;
 }
예제 #39
0
        private object ParamSwitch(FamilyParameter param, FamilyType type)
        {
            object value = String.Empty;
            try
            {
                var paramType = param.StorageType;
                switch (paramType)
                {
                    case StorageType.String:
                        value = type.AsString(param);
                        if (value != null)
                        {
                            value = value as String;
                        }
                        break;
                    case StorageType.Integer:
                        value = type.AsValueString(param);
                        break;
                    case StorageType.Double:
                        value = type.AsValueString(param);
                        break;
                    case StorageType.ElementId:
                        value = String.Empty;
                        break;
                }
            }
            catch (Exception)
            {

            }
            return value;
        }
        static string FamilyParamValueString(
            FamilyType t,
            FamilyParameter fp,
            Document doc)
        {
            string value = t.AsValueString( fp );
              switch( fp.StorageType )
              {
            case StorageType.Double:
              value = Util.RealString(
            ( double ) t.AsDouble( fp ) )
            + " (double)";
              break;

            case StorageType.ElementId:
              ElementId id = t.AsElementId( fp );
              Element e = doc.GetElement( id );
              value = id.IntegerValue.ToString() + " ("
            + Util.ElementDescription( e ) + ")";
              break;

            case StorageType.Integer:
              value = t.AsInteger( fp ).ToString()
            + " (int)";
              break;

            case StorageType.String:
              value = "'" + t.AsString( fp )
            + "' (string)";
              break;
              }
              return value;
        }
예제 #41
0
      Stream(ArrayList data, FamilyType famType)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(FamilyType)));

         data.Add(new Snoop.Data.String("Name", famType.Name));
      }
예제 #42
0
 private void SetFormula(Document familyDoc)
 {
     _type = familyDoc.FamilyManager.NewType(_name);
     string newParamName = "Program Area";
     //
     //familyDoc.FamilyManager.AddParameter("Area", BuiltInParameterGroup.PG_CONSTRAINTS, ParameterType.Area, true);
     // replaced by line below
     ParameterBinding paramBind = new ParameterBinding(familyDoc, "Areas", newParamName);
     //
     //FamilyParameter param = familyDoc.FamilyManager.get_Parameter("Area");
     // replaced by line below
     FamilyParameter param = familyDoc.FamilyManager.get_Parameter(newParamName);
     if (null != param)
     {
         familyDoc.FamilyManager.Set(param, _area);
     }
     param = familyDoc.FamilyManager.get_Parameter("Height");
     if (null != param)
     {
         // familyDoc.FamilyManager.SetFormula(param, @"Area / Width");
         familyDoc.FamilyManager.SetFormula(param, @"Program Area / Width");
     }
 }