コード例 #1
0
        public DetailCurve DetailCurveToSpeckle(DB.DetailCurve revitCurve)
        {
            var speckleCurve = new DetailCurve(CurveToSpeckle(revitCurve.GeometryCurve), revitCurve.LineStyle.Name);

            speckleCurve.elementId     = revitCurve.Id.ToString();
            speckleCurve.applicationId = revitCurve.UniqueId;
            speckleCurve.units         = ModelUnits;
            return(speckleCurve);
        }
コード例 #2
0
        public List <ApplicationPlaceholderObject> DetailCurveToNative(DetailCurve speckleCurve)
        {
            var docObj = GetExistingElementByApplicationId(speckleCurve.applicationId);

            //delete and re-create line
            //TODO: check if can be modified
            if (docObj != null)
            {
                Doc.Delete(docObj.Id);
            }

            var placeholders = new List <ApplicationPlaceholderObject>();
            var crvEnum      = CurveToNative(speckleCurve.baseCurve).GetEnumerator();

            while (crvEnum.MoveNext() && crvEnum.Current != null)
            {
                var            baseCurve  = crvEnum.Current as DB.Curve;
                DB.DetailCurve revitCurve = null;
                try
                {
                    revitCurve = Doc.Create.NewDetailCurve(Doc.ActiveView, baseCurve);
                }
                catch (Exception)
                {
                    throw (new Exception($"Detail curve creation failed\nView is not valid for detail curve creation."));
                }

                var lineStyles  = revitCurve.GetLineStyleIds();
                var lineStyleId = lineStyles.FirstOrDefault(x => Doc.GetElement(x).Name == speckleCurve.lineStyle);
                if (lineStyleId != null)
                {
                    revitCurve.LineStyle = Doc.GetElement(lineStyleId);
                }
                placeholders.Add(new ApplicationPlaceholderObject()
                {
                    applicationId = speckleCurve.applicationId, ApplicationGeneratedId = revitCurve.UniqueId, NativeObject = revitCurve
                });
                Report.Log($"Created DetailCurve {revitCurve.Id}");
            }

            return(placeholders);
        }
コード例 #3
0
        public ApplicationPlaceholderObject DetailCurveToNative(DetailCurve speckleCurve)
        {
            var docObj = GetExistingElementByApplicationId(speckleCurve.applicationId);

            //TODO: support polybline/polycurve lines
            var baseCurve = CurveToNative(speckleCurve.baseCurve).get_Item(0);

            //delete and re-create line
            //TODO: check if can be modified
            if (docObj != null)
            {
                Doc.Delete(docObj.Id);
            }
            DB.DetailCurve revitCurve = null;
            try
            {
                revitCurve = Doc.Create.NewDetailCurve(Doc.ActiveView, baseCurve);
            }
            catch (Exception)
            {
                ConversionErrors.Add(new Error("Detail curve creation failed", $"View is not valid for detail curve creation."));
                throw;
            }

            var lineStyles  = revitCurve.GetLineStyleIds();
            var lineStyleId = lineStyles.FirstOrDefault(x => Doc.GetElement(x).Name == speckleCurve.lineStyle);

            if (lineStyleId != null)
            {
                revitCurve.LineStyle = Doc.GetElement(lineStyleId);
            }
            return(new ApplicationPlaceholderObject()
            {
                applicationId = speckleCurve.applicationId, ApplicationGeneratedId = revitCurve.UniqueId, NativeObject = revitCurve
            });
        }