Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Updating a Feature Line's geometry

4 REPLIES 4
Reply
Message 1 of 5
RasmusB
420 Views, 4 Replies

Updating a Feature Line's geometry

Does anyone know  of a way to update a Feature Line's geometry? Say, you have a db-resident Feature Line you want to keep (i.e. its ObjectId etc), but update, and a non-db resident Feature Line which has the new/updated geometry. I have tried opening the db-resident Feature Line as an Entity and calling Entity::handOverTo with the non-db resident Feature Line as input, but the resultng Feature Line behaves very strange (e.g. it disappears and reappears at different places during REGEN)...just removing and adding PIs is not so easy either, as there can be no less than two PIs on a Feature Line, and they have to be inserted close to a segment.

---
2B or not 2B? That is the question! The answer is FF.
4 REPLIES 4
Message 2 of 5
Partha.Sarkar
in reply to: RasmusB

Hi Rasmus,

 

I don't have any ready answer for this; I need to investigate this.

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
Jeff_M
in reply to: RasmusB

Just trying to do this inside one drawing, using the COM interops (since there is essentially no .NET functionality for Featurelines). This seems like it should work, and it all does, except for the part to InsertFeaturePoint(s) where it errors with E_FAIL.

 

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.Land.DatabaseServices;
using Autodesk.AECC.Interop.Land;

namespace FeaturelineTools
{
    public class EditFeatureLine
    {
        [CommandMethod("CopyFLData")]
        public void CopyFLDatacommand()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect Source Featureline line: ");
            entOpts.SetRejectMessage("\n...not an allowed object type, try again.");
            entOpts.AddAllowedClass(typeof(FeatureLine), true);
            entOpts.AddAllowedClass(typeof(Polyline3d), true);
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptEntityResult res = ed.GetEntity(entOpts);
                if (res.Status != PromptStatus.OK)
                    return;
                FeatureLine sourceFL = (FeatureLine)tr.GetObject(res.ObjectId, OpenMode.ForRead);
                entOpts.Message = "\nSelect Target Featureline: ";
                res = ed.GetEntity(entOpts);
                if (res.Status != PromptStatus.OK)
                    return;
                FeatureLine targetFL = (FeatureLine)tr.GetObject(res.ObjectId, OpenMode.ForRead);
                AeccLandFeatureLine src=(AeccLandFeatureLine)sourceFL.AcadObject;
                AeccLandFeatureLine trgt = (AeccLandFeatureLine)targetFL.AcadObject;
                double[] trgtelevpts = (double[])trgt.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointElevation);
                double[] trgtpipts = (double[])trgt.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI);
                double[] srcelevpts = (double[])src.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointElevation);
                double[] srcpipts = (double[])src.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI);
                double[] trgtstart = new double[3];
                trgtstart[0] = trgtpipts[0];
                trgtstart[1] = trgtpipts[1];
                trgtstart[2] = trgtpipts[2];
                int len = trgtpipts.GetLength(0);
                double[] trgtend = new double[3];
                trgtend[0] = trgtpipts[len - 3];
                trgtend[1] = trgtpipts[len - 2];
                trgtend[2] = trgtpipts[len - 1];

                for (int i = 3; i < (trgtelevpts.GetLength(0) - 3); i = i + 3)
                {
                    double[] pt = new double[3];
                    pt[0] = trgtelevpts[i];
                    pt[1] = trgtelevpts[i + 1];
                    pt[2] = trgtelevpts[i + 2];
                    trgt.DeleteFeaturePoint((object)pt);
                }
                for (int i = 3; i < (trgtpipts.GetLength(0) - 3); i = i + 3)
                {
                    double[] pt = new double[3];
                    pt[0] = trgtpipts[i];
                    pt[1] = trgtpipts[i + 1];
                    pt[2] = trgtpipts[i + 2];
                    trgt.DeleteFeaturePoint((object)pt);
                }
                trgt.Update();
                //the 2 following lines fail, so tried to set each point individually...which also fails with the same error E_FAIL
                //trgt.InsertFeaturePoints((object)srcpipts, AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI);
                //trgt.InsertFeaturePoints((object)srcelevpts, AeccLandFeatureLinePointType.aeccLandFeatureLinePointElevation);
                for (int i = 0; i < srcpipts.GetLength(0); i++)
                {
                    double[] pt = new double[3];
                    pt[0] = srcpipts[i];
                    pt[1] = srcpipts[i + 1];
                    pt[2] = srcpipts[i + 2];
                    trgt.InsertFeaturePoint((object)pt, AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI);
                }
                for (int i = 0; i < srcelevpts.GetLength(0); i++)
                {
                    double[] pt = new double[3];
                    pt[0] = srcelevpts[i];
                    pt[1] = srcelevpts[i + 1];
                    pt[2] = srcelevpts[i + 2];
                    trgt.InsertFeaturePoint((object)pt, AeccLandFeatureLinePointType.aeccLandFeatureLinePointElevation);
                }
                trgt.DeleteFeaturePoint((object)trgtstart);
                trgt.DeleteFeaturePoint((object)trgtend);
                tr.Commit();
            }
        }
    }
}

 

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 5
rasmusfb
in reply to: Jeff_M

My point exactly. I have tried this and similar strategies, but they all fail as long as the points you try to insert are not sufficiently close to the (single) segment on the Feature Line of interest (and in general, the points are not close). This is expected as it is the same behaviour one get when trying to insert PIs on a Feature Line within Civil 3D.

Message 5 of 5
Partha.Sarkar
in reply to: rasmusfb

This functionality needs to be exposed in .NET API for FeatureLine class.

 

I would suggest to submit a wish list for the same.

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report