<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating profile from file in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8198887#M10975</link>
    <description>&lt;P&gt;Awesome! This definitely gives me everything I need.&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt; Thanks!!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Aug 2018 15:56:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-08-14T15:56:08Z</dc:date>
    <item>
      <title>Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8187626#M10970</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cr_pf_fr_fl.png" style="width: 480px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/532729i0345045F2EB1A848/image-size/large?v=v2&amp;amp;px=999" role="button" title="cr_pf_fr_fl.png" alt="cr_pf_fr_fl.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there any way to call this command without the dialog box. it would be nice to get away from the file selection box by passing it as an argument to a lisp function. Even better if the following box&amp;nbsp;&lt;EM&gt;Create Profile - Draw New&amp;nbsp;&amp;nbsp;&lt;/EM&gt;could be bypassed? Any thoughts ideas? I know LISP, so would prefer a LISP solution. I have no .net experience. But am willing to experiment if anyone can push me to a specific method available in the API? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 23:21:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8187626#M10970</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-08T23:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8189759#M10971</link>
      <description>&lt;P&gt;AFAIK, activeX does not provide any method for this. Not sure about .net&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 18:59:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8189759#M10971</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2018-08-09T18:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8192669#M10972</link>
      <description>&lt;P&gt;This is .net (c#) sample for creating a profile, based on two points.&lt;/P&gt;&lt;PRE&gt;        public static void CreateProfileNoSurface(Alignment oAlignment)
        {
            CivilDocument civDoc = CivilApplication.ActiveDocument;

            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {

                // use the same layer as the alignment
                ObjectId layerId = oAlignment.LayerId;

                // get the standard style and label set 
                // these calls will fail on templates without a style named "Standard"
                ObjectId styleId = civDoc.Styles.ProfileStyles["Standard"];
                ObjectId labelSetId = civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles["Standard"];

                // create a new empty profile
                ObjectId oProfileId = Profile.CreateByLayout("MyProfile", oAlignment.Id, layerId, styleId, labelSetId);

                // Now add the entities that define the profile.
                Profile oProfile = ts.GetObject(oProfileId, OpenMode.ForRead) as Profile;

                Point2d startPoint = new Point2d(oAlignment.StartingStation, 40);
                Point2d endPoint = new Point2d(oAlignment.EndingStation, -70);
                ProfileTangent oTangent1 = oProfile.Entities.AddFixedTangent(startPoint, endPoint);

                ts.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can enclose this in a while loop, reading and parsing the text file line and adding entity. You can find plenty of sample of reading and parsing text files in the AutoCAD development&amp;nbsp; forum.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/reading-data-from-a-txt-file-using-c/td-p/6005943" target="_blank"&gt;https://forums.autodesk.com/t5/net/reading-data-from-a-txt-file-using-c/td-p/6005943&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 21:02:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8192669#M10972</guid>
      <dc:creator>lu_an_jie</dc:creator>
      <dc:date>2018-08-10T21:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8194155#M10973</link>
      <description>&lt;P&gt;Do you have a sample file, so I can test some code.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 16:32:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8194155#M10973</guid>
      <dc:creator>lu_an_jie</dc:creator>
      <dc:date>2018-08-12T16:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8197098#M10974</link>
      <description>&lt;P&gt;Here's some&amp;nbsp;code that shows how this can be done using lisp. You can take this as a starting point to create the function which accepts the file name, profile name, and profile style name. Hope it helps!&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(if (setq ss (ssget ":S" '((0 . "AECC_ALIGNMENT"))))
  (progn
    (setq alignment (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
    (setq profile (vlax-invoke (vlax-get alignment 'profiles) 'Add "NewProfileFromFile" 2 "Basic")) ;;the 2 is for a FinishGrade profile
    (setq pvis (vlax-get profile 'PVIs))
    (setq f (open "C:\\TestFiles\\Profiledata.txt" "r"));;this file must be in the format defined by C3D for profiles from a file
    (while (setq ln (read-line f))
      (setq data (str2list ln " "))
      (if (= 2 (length data))
	(setq pvi (vlax-invoke pvis 'add (atof (nth 0 data)) (atof (nth 1 data)) 1 nil nil));;the 1 tells C3D this a Tangent PVI
	(setq pvi (vlax-invoke pvis 'add (atof (nth 0 data)) (atof (nth 1 data)) 3 (atof (nth 2 data)) nil));;the 3 tells C3D it is a parabolic VC
	)
      )
    (close f)
    )
  )

;;;str2list by John Uhden, as posted to the adesk customization newsgroup a long time ago
(defun Str2List (str pat / i j n lst)
  (cond
    ((/= (type str)(type pat) 'STR))
    ((= str pat)'(""))
    (T
      (setq i 0 n (strlen pat))
      (while (setq j (vl-string-search pat str i))
        (setq lst (cons (substr str (1+ i)(- j i)) lst)
              i (+ j n)
        )
      )
      (reverse (cons (substr str (1+ i)) lst))
    )
  )
)
    &lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 00:53:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8197098#M10974</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2018-08-14T00:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8198887#M10975</link>
      <description>&lt;P&gt;Awesome! This definitely gives me everything I need.&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt; Thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:56:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8198887#M10975</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-14T15:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8256469#M10976</link>
      <description>&lt;P&gt;Hi Jeff&lt;/P&gt;&lt;P&gt;I came across your Lisp code&amp;nbsp;with some surprise believing such manipulation of the civil&lt;/P&gt;&lt;P&gt;3d database wasn't possible, a bitter sweet moment, spent last six months learning vb.net.&lt;/P&gt;&lt;P&gt;First question should this still&amp;nbsp;&amp;nbsp;work in Civil 3d 2018 and if so why does my lisp fall over at this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq profile (vlax-invoke (vlax-get alignment 'profiles) 'Add "NewProfileFromFile" 2 "Basic"))&lt;/P&gt;&lt;P&gt;; error: Civil 3D API: The parameter is incorrect.&lt;/P&gt;&lt;P&gt;I presume it similar to the C# code&lt;/P&gt;&lt;P&gt;ObjectId oProfileId = Profile.CreateByLayout("MyProfile", oAlignment.Id, layerId, styleId, labelSetId);&lt;/P&gt;&lt;P&gt;Any assistance will be greatly appreciated&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Trefor&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 08:46:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8256469#M10976</guid>
      <dc:creator>treforfjones</dc:creator>
      <dc:date>2018-09-10T08:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8256965#M10977</link>
      <description>Yes, Trefor, this should still be fine in C3D2018. Does your drawing have the profile style named Basic?</description>
      <pubDate>Mon, 10 Sep 2018 12:58:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8256965#M10977</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2018-09-10T12:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8259514#M10978</link>
      <description>&lt;P&gt;Hi Jeff&lt;/P&gt;&lt;P&gt;Thanks for the prompt reply&lt;/P&gt;&lt;P&gt;I've enclosed a jpeg of the profile label sets in use ?&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Trefor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 09:28:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8259514#M10978</guid>
      <dc:creator>treforfjones</dc:creator>
      <dc:date>2018-09-11T09:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8260570#M10979</link>
      <description>&lt;P&gt;The "Basic" in&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;s' code is referring to profile style and not label sets. Change the drop-down list above the tree view to either &lt;EM&gt;Active Drawing Settings View&amp;nbsp;&lt;/EM&gt;or&amp;nbsp;&lt;EM&gt;Master View, and then look under&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;Profile&amp;nbsp;&lt;/EM&gt;for the available styles and use one of those styles&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prof_styles.png" style="width: 260px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/545001iD1F95DBF92CAF575/image-size/large?v=v2&amp;amp;px=999" role="button" title="prof_styles.png" alt="prof_styles.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 15:43:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8260570#M10979</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2018-09-11T15:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8260602#M10980</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3676355"&gt;@treforfjones&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The COM API arguments are as follows (from the help file): Profiles.Add(name, profile type, profile style), which is much different than the .NET API counterpart.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 15:54:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8260602#M10980</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2018-09-11T15:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8265029#M10981</link>
      <description>&lt;P&gt;Hi Jeff&lt;/P&gt;&lt;P&gt;Thanks that code is now working&lt;/P&gt;&lt;P&gt;Have you any similar lisp snippets that convert polylines to alignments&lt;/P&gt;&lt;P&gt;I've spent the last six months learning vb.net. Given your lisp experience&lt;/P&gt;&lt;P&gt;do you think C#&amp;nbsp;is a better bet, long term to learn or&lt;/P&gt;&lt;P&gt;can I achieve a lot more with lisp&amp;nbsp;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Trefor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:20:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8265029#M10981</guid>
      <dc:creator>treforfjones</dc:creator>
      <dc:date>2018-09-13T08:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8266704#M10982</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3676355"&gt;@treforfjones&lt;/a&gt;, lisp is limited for use with C3D. All of the API work since C3D 2012 has been for the .NET API. The COM API was last updated/added to in C3D 2012. I much prefer to use c# for .NET development...VB is something I decided to leave back in VBA.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do still use lisp for small, quick, things, but anything that I want to be fast and powerful I use c#.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 18:57:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8266704#M10982</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2018-09-13T18:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8268827#M10983</link>
      <description>&lt;P&gt;It doesn't matter which programming language as long it is a .NET language (VB.NET, C# OR F# i.e.). You can even mix and match and creating different libraries in different languages in the same project as long you are targeting the same .NET framework.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Autodesk developer's documentation you&amp;nbsp;can find all the sample code in VB.NET AS WELL AS IN C#.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Start with whichever language you feel more comfortable personally. The “language part” is something you can learn or re-learn in a matter of 1-3 days. What you are&amp;nbsp;&lt;I&gt;really&amp;nbsp;&lt;/I&gt;learning here is the .NET: collections, interfaces, anonymous functions&amp;nbsp;LINQ,&amp;nbsp;MVC, XAML, WPF, Entity Framework and so on and so forth.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the C# version for creating a polyline from a single alignment.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;Here is same sample code, cha// (C) Copyright 2018 by Andreas Luka


using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(LX_PolyLine.MyCommands))]

namespace LX_PolyLine
{

    public class MyCommands
    {

        // Modal Command with pickfirst selection
        [CommandMethod("MyGroup", "LX-Polyline", CommandFlags.Modal)]
        public void AlignToPoly() 
        {
            // Getting the autodesk database (needed for transaction)
            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            // Getting the editor object (needed for error messaging)
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            // Getting the civil document object (need for check of alignments presence)
            CivilDocument cd = CivilApplication.ActiveDocument;

            // Getting the list of all alignments in an collection of the ids
            ObjectIdCollection alignIds = cd.GetAlignmentIds();

            // Getting out if there are no alignments in drawing
            if (alignIds.Count == 0)
            {
                ed.WriteMessage("\nNo alignments in drawing.");
                return;
            }

            // Calling function to select a single alignment
            ObjectId alignId = SelectAlignment();

            // Getting out if the selection failes
            if (alignId == ObjectId.Null) return;

            // Getting the alignment from his id and creating the polyline
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    Alignment align = (Alignment)alignId.GetObject(OpenMode.ForRead);
                    ObjectId plId = align.GetPolyline();
                }
                catch { }
                tr.Commit();
            }
        }


        // This function select an Alignment and returns his ObjectId or Null in case of Cancelation or Error
        public static ObjectId SelectAlignment()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            // Setting ObjectId to Null 
            ObjectId result = ObjectId.Null;

            // Creating the promt option for a single entity prompt
            PromptEntityOptions prOptions = new PromptEntityOptions("\nSelect alignment: ");
            prOptions.SetRejectMessage("...not an Alignment, try again!:");
            prOptions.AddAllowedClass(typeof(Alignment), true);
            
            // Getting the selected element from the editor
            PromptEntityResult prResult = ed.GetEntity(prOptions);

            // Returning the selected alignment's id
            if (prResult.Status == PromptStatus.OK) result = prResult.ObjectId;
            return result;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:03:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/8268827#M10983</guid>
      <dc:creator>lu_an_jie</dc:creator>
      <dc:date>2018-09-14T15:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9705769#M10984</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;God willing, your health is good&lt;/P&gt;&lt;P&gt;A question ...&lt;/P&gt;&lt;P&gt;I have a road profile&lt;/P&gt;&lt;P&gt;As it is in the picture or drawing&lt;/P&gt;&lt;P&gt;And I wrote in a file notebook&lt;BR /&gt;The STATION&amp;nbsp; AND LEVEL&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;&lt;P&gt;The STATION&amp;nbsp; AND LEVEL&amp;nbsp; &amp;nbsp;AND&amp;nbsp; LENGTH&lt;/P&gt;&lt;LI-CODE lang="general"&gt;0 10.406
55 11 21.50
80 9.62 2.38
98.0 9.62&lt;/LI-CODE&gt;&lt;P&gt;In order to draw it through&lt;BR /&gt;Creating profile from file ...&amp;nbsp;Imported and profile drawn&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PP.jpg" style="width: 320px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/810096i3426EA5B2F7E6097/image-size/large?v=v2&amp;amp;px=999" role="button" title="PP.jpg" alt="PP.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 392px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/810095i1EEDF03984933F1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But&lt;BR /&gt;When I use the code there is a problem&lt;BR /&gt;Could you please&lt;BR /&gt;What is the reason? Is writing notepad a mistake&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="PROFILE" href="http://www.mediafire.com/file/6qd5vtzgmobmlos/PROFILE+_++CIVIL+2021.dwg/file" target="_blank" rel="noopener"&gt;http://www.mediafire.com/file/6qd5vtzgmobmlos/PROFILE+_++CIVIL+2021.dwg/file&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 06:21:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9705769#M10984</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2020-08-22T06:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706082#M10985</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997"&gt;@hosneyalaa&lt;/a&gt;&amp;nbsp;&amp;nbsp;What problem are you seeing?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 15:52:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706082#M10985</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2020-08-22T15:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706146#M10986</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Command: TEST
Select objects:
; error: AutoCAD.Application: Invalid input
Command:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="التقاط.PNG" style="width: 702px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/810174i32A078589AF3BDA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="التقاط.PNG" alt="التقاط.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:test ( / ALIGNMENT DATA F LN PROFILE PVI PVIS SS)
(vl-load-com)
(if (setq ss (ssget ":S" '((0 . "AECC_ALIGNMENT"))))
  (progn
    (setq alignment (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
    (setq profile (vlax-invoke (vlax-get alignment 'profiles) 'Add "NewProfileFromFile" 2 "Basic")) ;;the 2 is for a FinishGrade profile
    (setq pvis (vlax-get profile 'PVIs))
    (setq	FilePath (getfiled "Select TEXT file to read :"
			   (getvar "dwgprefix")
			   "txt"
			   4
		 )
  )
    (setq f (open FilePath "r"));;this file must be in the format defined by C3D for profiles from a file
    (while (setq ln (read-line f))
      (setq data (str2list ln " "))
      (if (= 2 (length data))
	(setq pvi (vlax-invoke pvis 'add (atof (nth 0 data)) (atof (nth 1 data)) 1 nil nil));;the 1 tells C3D this a Tangent PVI
	(setq pvi (vlax-invoke pvis 'add (atof (nth 0 data)) (atof (nth 1 data)) 3 (atof (nth 2 data)) nil));;the 3 tells C3D it is a parabolic VC
	)
      )
    (close f)
    )
  )
)
;;;str2list by John Uhden, as posted to the adesk customization newsgroup a long time ago
(defun Str2List (str pat / i j n lst)
  (cond
    ((/= (type str)(type pat) 'STR))
    ((= str pat)'(""))
    (T
      (setq i 0 n (strlen pat))
      (while (setq j (vl-string-search pat str i))
        (setq lst (cons (substr str (1+ i)(- j i)) lst)
              i (+ j n)
        )
      )
      (reverse (cons (substr str (1+ i)) lst))
    )
  )
)
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;0 10.406
55 11 21.50
80 9.62 2.38
98.0 9.62&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 17:20:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706146#M10986</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2020-08-22T17:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706197#M10987</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997"&gt;@hosneyalaa&lt;/a&gt;&amp;nbsp;Yes, there was an issue due to the vertical curves. You cannot have a VC without 2 tangents, which I did not account for. To solve this, I changed the code so it creates the first and last PVIs before adding the internal PVIs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;(defun c:test (/ ALIGNMENT F DATA LN PROFILE PVI PVIS SS)
  (vl-load-com)
  (if (setq ss (ssget ":S" '((0 . "AECC_ALIGNMENT"))))
    (progn
      (setq FilePath (getfiled "Select TEXT file to read :"
			       (getvar "dwgprefix")
			       "txt"
			       4
		     )
      )
      (if filepath
	(progn
	  (setq f (open FilePath "r"))
	  (setq alignment (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
	  (setq profile (vlax-invoke (vlax-get alignment 'profiles) 'Add "NewProfileFromFile" 2 "Basic"))
	  ;;the 2 is for a FinishGrade profile
	  (setq pvis (vlax-get profile 'PVIs))
	  ;;this file must be in the format defined by C3D for profiles from a file
	  (while (setq ln (read-line f))
	    (setq data (cons (str2list ln " ") data))
	    )
	  (close f)
	  (setq data (reverse data))
	  ;;create the first and last PVIs before adding the internal PVIs
	  (vlax-invoke pvis 'add (atof (nth 0 (car data))) (atof (nth 1 (car data))) 1 nil nil)
	  (vlax-invoke pvis 'add (atof (nth 0 (last data))) (atof (nth 1 (last data))) 1 nil nil)
	  (setq i 0)
	  (while (&amp;lt; (setq i (1+ i)) (- (length data) 1))
	    (setq d (nth i data))
	    (if (= 2 (length d))
	      (vlax-invoke pvis 'add (atof (nth 0 d)) (atof (nth 1 d)) 1 nil nil)
	      ;;the 1 tells C3D this a Tangent PVI
	      (vlax-invoke pvis 'add (atof (nth 0 d)) (atof (nth 1 d)) 3 (atof (nth 2 d)) nil)
	      ;;the 3 tells C3D it is a parabolic VC
	      )
	    )
	  )
	)
      )
    )
  )

;;;str2list by John Uhden, as posted to the adesk customization newsgroup a long time ago
(defun Str2List	(str pat / i j n lst)
  (cond
    ((/= (type str) (type pat) 'STR))
    ((= str pat) '(""))
    (T
     (setq i 0
	   n (strlen pat)
     )
     (while (setq j (vl-string-search pat str i))
       (setq lst (cons (substr str (1+ i) (- j i)) lst)
	     i	 (+ j n)
       )
     )
     (reverse (cons (substr str (1+ i)) lst))
    )
  )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 22 Aug 2020 18:32:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706197#M10987</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2020-08-22T18:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706221#M10988</link>
      <description>&lt;P&gt;My teacher mister&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I am unable to thank you&lt;BR /&gt;You are a great person for this problem solving group&lt;BR /&gt;Thank you so much&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 19:19:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/9706221#M10988</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2020-08-22T19:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating profile from file</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/12859630#M10989</link>
      <description>&lt;P&gt;VERTICAL FALL TOP AND BOTTOM ELEVATION ISSU&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 08:28:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-profile-from-file/m-p/12859630#M10989</guid>
      <dc:creator>azhar_abbas9104ZVUC</dc:creator>
      <dc:date>2024-06-25T08:28:07Z</dc:date>
    </item>
  </channel>
</rss>

