i know 2013 are more exposed and the .net can extract contours.
however using 2012 at the moment. so my plan is using .net to add the user contours and then use com object to extract.
so far i can get the surface object and asign to two differnt surface variable one is .net and one is com.
i am looking at the surfaceanalysis object and can't figure out how to add contours at user elevation. it is also read only in the surface object. but i find this:
SetContourData
(analysisData()
which is obvious not read only.
so anybody have a sample code of the procedure of assign user contours?
thank you.
For each UserDefinedContour you need to create a SurfaceAnalysisUserDefinedContourData() and add it to an array of SurfaceAnalysisUserDefinedContourData[] This array is passed to the SetUserDefinedContourData method of the SurfaceAnalysis.
When you create a new instance of SurfaceAnalysisUserDefinedContourData(), it uses the dtatbase defaults, then you can set the Elevation desired for that UDC.
hi jeff
can you like put that in a "sentence" : )
can't figure out still.
Here ya go, Bob.
using System.Collections.Generic; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Colors; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autodesk.Civil.Land.DatabaseServices; using CivDb = Autodesk.Civil.Land.DatabaseServices; namespace C3D_Surface_Test { public class SurfaceTest { [CommandMethod("TestUserContours")] public void testusercontours() { Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions pmptEnt = new PromptEntityOptions("\nSelect entity:"); pmptEnt.SetRejectMessage("Not a Surface, try again!"); pmptEnt.AddAllowedClass(typeof(CivDb.Surface), false); PromptEntityResult entRes = ed.GetEntity(pmptEnt); if (entRes.Status != PromptStatus.OK) return; using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { LinetypeTable ltt = (LinetypeTable)db.LinetypeTableId.GetObject(OpenMode.ForRead); ObjectId ltId = ltt["HIDDEN"]; LineWeight lw = LineWeight.LineWeight015; Color color = new Color(); color = Color.FromColorIndex(ColorMethod.ByColor, 1); CivDb.Surface surf = (CivDb.Surface)entRes.ObjectId.GetObject(OpenMode.ForWrite); double[] elevs = { 2.2, 3.7, 4.5 }; List<double> contourelevations = new List<double>(elevs); List<SurfaceAnalysisUserDefinedContourData> data = new List<SurfaceAnalysisUserDefinedContourData>(); foreach (double elev in contourelevations) { SurfaceAnalysisUserDefinedContourData ucd = new SurfaceAnalysisUserDefinedContourData();//elev,, color, ltId, lw); //using the full constructor fails with the ltId... ucd.Elevation = elev; ucd.Color = color; ucd.LineTypeId = ltId; ucd.LineWeight = lw; data.Add(ucd); } surf.Analysis.SetUserDefinedContourData(data.ToArray()); tr.Commit(); } } } }