コード例 #1
0
 public GraphicsStyle(DB.GraphicsStyle graphicsStyle) : base(graphicsStyle)
 {
 }
コード例 #2
0
        void Add
        (
            DB.Document doc,
            DB.Document familyDoc,
            Rhino.Geometry.Curve curve,
            List <KeyValuePair <double[], DB.SketchPlane> > planesSet,
            DeleteElementEnumerator <DB.CurveElement> curves
        )
        {
            if (curve.TryGetPlane(out var plane))
            {
                var abcd  = plane.GetPlaneEquation();
                int index = planesSet.BinarySearch(new KeyValuePair <double[], DB.SketchPlane>(abcd, null), PlaneComparer.Instance);
                if (index < 0)
                {
                    var entry = new KeyValuePair <double[], DB.SketchPlane>(abcd, DB.SketchPlane.Create(familyDoc, plane.ToPlane()));
                    index = ~index;
                    planesSet.Insert(index, entry);
                }
                var sketchPlane = planesSet[index].Value;

                DB.GraphicsStyle familyGraphicsStyle = null;
                {
                    DB.Category familySubCategory = null;
                    if
                    (
                        curve.TryGetUserString(DB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY.ToString(), out DB.ElementId subCategoryId) &&
                        DB.Category.GetCategory(doc, subCategoryId) is DB.Category subCategory
                    )
                    {
                        if (subCategoryId == familyDoc.OwnerFamily.FamilyCategory.Id)
                        {
                            familySubCategory = MapCategory(doc, familyDoc, subCategoryId, true);
                        }
                        else if (subCategory?.Parent?.Id == familyDoc.OwnerFamily.FamilyCategory.Id)
                        {
                            familySubCategory = MapCategory(doc, familyDoc, subCategoryId, true);
                        }
                        else
                        {
                            if (subCategory.Parent is null)
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"'{subCategory.Name}' is not subcategory of '{familyDoc.OwnerFamily.FamilyCategory.Name}'");
                            }
                            else
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"'{subCategory.Parent.Name} : {subCategory.Name}' is not subcategory of '{familyDoc.OwnerFamily.FamilyCategory.Name}'");
                            }
                        }
                    }

                    curve.TryGetUserString(DB.BuiltInParameter.FAMILY_CURVE_GSTYLE_PLUS_INVISIBLE.ToString(), out var graphicsStyleType, DB.GraphicsStyleType.Projection);

                    familyGraphicsStyle = familySubCategory?.GetGraphicsStyle(graphicsStyleType);
                }

                curve.TryGetUserString(DB.BuiltInParameter.MODEL_OR_SYMBOLIC.ToString(), out bool symbolic, false);
                curve.TryGetUserString(DB.BuiltInParameter.IS_VISIBLE_PARAM.ToString(), out var visible, true);
                curve.TryGetUserString(DB.BuiltInParameter.GEOM_VISIBILITY_PARAM.ToString(), out var visibility, 57406);

                foreach (var c in curve.ToCurveMany())
                {
                    curves.MoveNext();

                    if (symbolic)
                    {
                        if (curves.Current is DB.SymbolicCurve symbolicCurve && symbolicCurve.GeometryCurve.IsSameKindAs(c))
                        {
                            symbolicCurve.SetSketchPlaneAndCurve(sketchPlane, c);
                            curves.DeleteCurrent = false;
                        }
                        else
                        {
                            symbolicCurve = familyDoc.FamilyCreate.NewSymbolicCurve(c, sketchPlane);
                        }

                        symbolicCurve.get_Parameter(DB.BuiltInParameter.IS_VISIBLE_PARAM).Set(visible ? 1 : 0);
                        symbolicCurve.get_Parameter(DB.BuiltInParameter.GEOM_VISIBILITY_PARAM).Set(visibility);

                        if (familyGraphicsStyle is object)
                        {
                            symbolicCurve.Subcategory = familyGraphicsStyle;
                        }
                    }
                    else
                    {
                        if (curves.Current is DB.ModelCurve modelCurve && modelCurve.GeometryCurve.IsSameKindAs(c))
                        {
                            modelCurve.SetSketchPlaneAndCurve(sketchPlane, c);
                            curves.DeleteCurrent = false;
                        }
コード例 #3
0
ファイル: Category.cs プロジェクト: scottdeisher/rhino.inside
 public GraphicsStyle(Autodesk.Revit.DB.GraphicsStyle graphicsStyle) : base(graphicsStyle)
 {
 }