Beispiel #1
0
        public List <ApplicationPlaceholderObject> ModelCurveToNative(ModelCurve 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 curves          = CurveToNative(speckleCurve.baseCurve);
            var placeholders    = new List <ApplicationPlaceholderObject>();
            var curveEnumerator = curves.GetEnumerator();

            while (curveEnumerator.MoveNext() && curveEnumerator.Current != null)
            {
                var           baseCurve  = curveEnumerator.Current as DB.Curve;
                DB.ModelCurve revitCurve = Doc.Create.NewModelCurve(baseCurve, NewSketchPlaneFromCurve(baseCurve, Doc));

                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 ModelCurve {revitCurve.Id}");
            }

            return(placeholders);
        }
Beispiel #2
0
        public ApplicationPlaceholderObject ModelCurveToNative(ModelCurve speckleCurve)
        {
            var docObj = GetExistingElementByApplicationId(speckleCurve.applicationId);

            //TODO: support poliline/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.ModelCurve revitCurve = Doc.Create.NewModelCurve(baseCurve, NewSketchPlaneFromCurve(baseCurve));

            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
            });
        }
Beispiel #3
0
        public ModelCurve ModelCurveToSpeckle(DB.ModelCurve revitCurve)
        {
            var speckleCurve = new ModelCurve(CurveToSpeckle(revitCurve.GeometryCurve), revitCurve.LineStyle.Name);

            speckleCurve.elementId     = revitCurve.Id.ToString();
            speckleCurve.applicationId = revitCurve.UniqueId;
            speckleCurve.units         = ModelUnits;
            return(speckleCurve);
        }