private ConceptualPlot BuildConceptualPlot(FoundationInput input, Document doc, Transaction trans)
        {
            ConceptualPlot plot;

            DataService.Current.PopulateStoreTypes();
            SoilProperties props = DataService.Current.GetStore <StructureDocumentStore>(doc.Name).SoilProperties;

            props.ExistingGroundSurfaceName = input.ExistingGround;
            props.ProposedGroundSurfaceName = input.ProposedGround;

            ObjectId obj = doc.Database.GetObjectId(false, new Handle(146034), 0);

            DBObject ent = trans.GetObject(obj, OpenMode.ForWrite);

            PolylineDrawingObject polyObject = new PolylineDrawingObject(ent as Polyline);

            plot = new ConceptualPlot(polyObject);

            CivSurface existingGround = GetSurface(props.ExistingGroundSurfaceName);
            CivSurface proposedGround = GetSurface(props.ProposedGroundSurfaceName);

            plot.EstimateFoundationLevel(existingGround, proposedGround, props);
            plot.RenderFoundations(props.DepthBands, null);
            return(plot);
        }
Example #2
0
        /*private void Button_selectInScreen_Click(object sender, System.Windows.RoutedEventArgs e)
         * {
         *  var control = (CivilSurfaces.Views.SurfaceSelectorUserControl)((System.Windows.Controls.Grid)(((System.Windows.Controls.Button)sender).Parent)).Parent;
         *  Autodesk.AutoCAD.Windows.Palette p = (Autodesk.AutoCAD.Windows.Palette)control.Tag;
         *  var surfInfos = (Dictionary<string, ObjectId>)control.comboBox_surfaces.Tag;
         *  ObjectId sid = ObjectId.Null;
         *  if (control.comboBox_surfaces.SelectedItem != null)
         *  {
         *      sid = surfInfos[control.comboBox_surfaces.SelectedItem.ToString()];
         *      control.button.Tag = sid;
         *  }
         *  p.PaletteSet.Visible = false;
         * }*/

        private double?_getElevationAtPoint(Point3d point, CivilSurface surface, Polyline polygon)
        {
            if (!polygon.IsInsidePolygon(point))
            {
                return(null);
            }
            double res = surface.FindElevationAtXY(point.X, point.Y);

            return(res);
        }
Example #3
0
        public TypedValue RebuildSurface(ResultBuffer resbuf)
        {
            var nil = new TypedValue((int)LispDataType.Nil);
            var T   = new TypedValue((int)LispDataType.T_atom);

            if (BufferContainsObjectId(resbuf) == false)
            {
                return(nil);
            }
            // get the actual value of the resbuf
            var      args = resbuf.AsArray();
            ObjectId oID  = (ObjectId)args[0].Value;

            Document currentDocument = Application.DocumentManager.MdiActiveDocument;
            Database currentDatabase = currentDocument.Database;

            using (Transaction trans = currentDatabase.TransactionManager.StartTransaction())
            {
                try
                {
                    //check if the oID belongs to a surface
                    Autodesk.Civil.DatabaseServices.Surface surface = oID.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
                    // make sure it's not a reference object
                    // check if the civil object is a data reference
                    if (surface != null)
                    {
                        if (surface.IsReferenceObject == false)
                        {
                            // rebuild the object
                            surface.Rebuild();
                            return(T);
                        }
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(nil);
                }
            }

            // return nil as the final output option
            return(nil);
        }
        private CivSurface GetSurface(string name)
        {
            //Get the target surface
            ObjectIdCollection SurfaceIds = CivilApplication.ActiveDocument.GetSurfaceIds();

            foreach (ObjectId surfaceId in SurfaceIds)
            {
                // Direct cast is safe as collection is filtered down to surfaces by Autocad
                CivSurface temp = (CivSurface)surfaceId.GetObject(OpenMode.ForRead);

                // Continue is not used, incase user has set the same surface as both
                if (temp.Name == name)
                {
                    return(temp);
                }
            }

            return(null);
        }
        public void GetSurfaces()
        {
            //Get the target surface
            ObjectIdCollection SurfaceIds     = CivilApplication.ActiveDocument.GetSurfaceIds();
            SoilProperties     soilProperties = DataService.Current.GetStore <StructureDocumentStore>(this.HostDocument.Name).SoilProperties;

            foreach (ObjectId surfaceId in SurfaceIds)
            {
                // Direct cast is safe as collection is filtered down to surfaces by Autocad
                CivSurface temp = (CivSurface)surfaceId.GetObject(OpenMode.ForRead);

                // Continue is not used, incase user has set the same surface as both
                if (temp.Name == soilProperties.ProposedGroundSurfaceName)
                {
                    ProposedLevels = temp;
                }
                if (temp.Name == soilProperties.ExistingGroundSurfaceName)
                {
                    ExistingLevels = temp;
                }
            }
        }
        /// <summary>
        /// Get the list of surfaces and search by name
        /// </summary>
        /// <param name="name">Name of surface to search.
        /// Case sensitive.</param>
        /// <returns>ObjectId of the surface</returns>
        public static ObjectId GetSurfaceId(string name)
        {
            Database db = Application.DocumentManager.
                          MdiActiveDocument.Database;

            using (Transaction trans = db.
                                       TransactionManager.StartTransaction())
            {
                CivilDocument      civilDoc   = CivilApplication.ActiveDocument;
                ObjectIdCollection surfaceIds = civilDoc.GetSurfaceIds();
                foreach (ObjectId surfaceId in surfaceIds)
                {
                    CivilSurface surface =
                        trans.GetObject(surfaceId, OpenMode.ForRead)
                        as CivilSurface;
                    if (surface.Name == name)
                    {
                        return(surface.ObjectId);
                    }
                }
            }
            return(ObjectId.Null);
        }