Exemple #1
0
        public override DBObject DeepClone(
            DBObject dbObject, DBObject ownerObject,
            IdMapping idMap, bool isPrimary
            )
        {
            // First we deep clone the object via the parent

            DBObject res =
                base.DeepClone(dbObject, ownerObject, idMap, isPrimary);

            // Then we check for our XData

            if (PipeDrawOverrule.PipeRadiusForObject(res) > 0.0)
            {
                // A transaction is needed by the set function to access
                // the RegApp table - we could also assume the app name
                // is registered and have a separate implementation
                // not taking the transaction...
                // Just as we might also have chosen to remove the XData

                Transaction tr =
                    dbObject.Database.TransactionManager.StartTransaction();
                using (tr)
                {
                    PipeDrawOverrule.SetPipeRadiusOnObject(tr, res, 0.0);
                    tr.Commit();
                }
            }
            return(res);
        }
Exemple #2
0
        public override void Explode(Entity e, DBObjectCollection objs)
        {
            double radius = 0.0;

            if (e is DBObject)
            {
                radius = PipeDrawOverrule.PipeRadiusForObject(e);
            }

            if (radius > 0.0)
            {
                Line line = e as Line;

                if (line != null)
                {
                    if (!line.Id.IsNull && line.Length > 0.0)
                    {
                        // Draw a pipe around the line

                        Circle clr =
                            new Circle(
                                line.StartPoint,
                                line.EndPoint - line.StartPoint,
                                radius
                                );
                        ExtrudedSurface pipe = new ExtrudedSurface();
                        try
                        {
                            pipe.CreateExtrudedSurface(
                                clr, line.EndPoint - line.StartPoint, sweepOpts
                                );
                        }
                        catch
                        {
                            Document doc =
                                Application.DocumentManager.MdiActiveDocument;
                            doc.Editor.WriteMessage(
                                "\nFailed with CreateExtrudedSurface."
                                );
                        }
                        clr.Dispose();
                        objs.Add(pipe);
                    }
                    return;
                }
            }
            base.Explode(e, objs);
        }
Exemple #3
0
        public override void Explode(Entity e, DBObjectCollection objs)
        {
            double radius = 0.0;

            if (e is DBObject)
            {
                radius = PipeDrawOverrule.PipeRadiusForObject(e);
            }

            if (radius > 0.0)
            {
                Circle circle = e as Circle;

                if (circle != null)
                {
                    // Needed to avoid ill-formed swept surface

                    if (circle.Radius > radius)
                    {
                        // Draw a pipe around the cirle

                        Vector3d normal =
                            (circle.Center - circle.StartPoint).
                            CrossProduct(circle.Normal);
                        Circle clr =
                            new Circle(
                                circle.StartPoint, normal, radius
                                );
                        SweptSurface pipe = new SweptSurface();
                        pipe.CreateSweptSurface(clr, circle, sweepOpts);
                        clr.Dispose();
                        objs.Add(pipe);
                    }
                    return;
                }
            }
            base.Explode(e, objs);
        }