<?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: Reload LineTypes in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477814#M55398</link>
    <description>&lt;P&gt;Oh and if you are accessing a document from the application context (i.e. CommandFlags.Session) then you need to lock any document before you edit it, hence the DocumentLock.&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2012 16:39:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-30T16:39:44Z</dc:date>
    <item>
      <title>Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473300#M55389</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I Reload a linetype... the linetype already exists in the drawing...&lt;/P&gt;&lt;P&gt;But I want to update the linetype defintition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to open the linetyperecord... but what do I use to reload or re-define the linetablerecord.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;	Dim db As Database = ActiveDrawing.Database 
			Dim ed As Editor = editor

			Const filename As String = "SFR_LINETYPES.lin"
         
            Try
             
				Dim path As String = HostApplicationServices.Current.FindFile(filename, db, FindFileHint.Default)
				db.LoadLineTypeFile("*", path)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;IMG title="PLOTLINEWIDTH.png" border="0" align="center" src="https://forums.autodesk.com/t5/image/serverpage/image-id/29414i6CAE99279940573A/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="PLOTLINEWIDTH.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="reload linetype.png" border="0" align="center" src="https://forums.autodesk.com/t5/image/serverpage/image-id/29412i7CB0875128806E49/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="reload linetype.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 22:29:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473300#M55389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-25T22:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473400#M55390</link>
      <description>Came across a post over in the new AutoCAD DevBlog on this topic just yesterday. How to reload the line type in AutoCAD using AutoCAD.NET API: &lt;A target="_blank" href="http://adndevblog.typepad.com/autocad/2012/03/how-to-reload-the-line-type-in-autocad-using-autocadnet-api.html"&gt;http://adndevblog.typepad.com/autocad/2012/03/how-to-reload-the-line-type-in-autocad-using-autocadnet-api.html&lt;/A&gt; Is this what you're looking for? Art</description>
      <pubDate>Sat, 26 May 2012 05:06:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473400#M55390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-26T05:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473476#M55391</link>
      <description>&lt;P&gt;What about setting &lt;A href="http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ffa23ce210c4a30acaf-4feb.htm" target="_self"&gt;EXPERT&lt;/A&gt; system variable in value &amp;gt;= 3?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2012 09:35:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3473476#M55391</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-26T09:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3476064#M55392</link>
      <description>&lt;P&gt;Those solutions don't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to delete the linetype and then reimport or re-define it completely.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For whatever reason It's not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autocad 2011&amp;nbsp;&lt;/P&gt;&lt;P&gt;Windows XP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 17:52:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3476064#M55392</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-29T17:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477040#M55393</link>
      <description>&lt;P&gt;using art's reference above, viru says that a drawing's line type definitions get updated when its .lin file is loaded (as you show in your post).&amp;nbsp;therefore as long as&amp;nbsp;your drawing continues to use its .lin file,&amp;nbsp;the line type definition in the .lin file&amp;nbsp;has to be changed (presuming the line type name stays the same)&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 09:50:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477040#M55393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-30T09:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477120#M55394</link>
      <description>&lt;P&gt;If CommanfFlags is set to Session&lt;/P&gt;&lt;P&gt;you have use LockDocument, i.e.:&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("relaodLinetype", CommandFlags.Session)]

        public static void relaodLinetype()
        {
            // Set full path of .LIN file herer:
            string linfile = @"C:\Test\SFR_LINETYPES.lin";

            DocumentCollection docManager = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;

            Database db = docManager.MdiActiveDocument.Database;

            using (DocumentLock doclock = docManager.MdiActiveDocument.LockDocument())
            {
                Transaction trans = db.TransactionManager.StartTransaction();

                bool bReload = false;

                using (trans)
                {

                    LinetypeTable table = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;

                    if (table.Has("CENTER"))

                        bReload = true;

                }

                System.Int16 fileDia = (System.Int16)

                    Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("FILEDIA");

                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("FILEDIA", 0);

                //reload using linetype command...

                Object acadObject = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;

                object ActiveDocument =
                    acadObject.GetType().InvokeMember("ActiveDocument", System.Reflection.BindingFlags.GetProperty, null, acadObject, null);

                object[] dataArry = new object[1];

                if (bReload)
                {
                    dataArry[0] = "-linetype Load CENTER\n" + linfile + "\nYes\n ";
                }
                else
                {
                    dataArry[0] = "-linetype Load CENTER\nacad.lin\n ";
                }
                ActiveDocument.GetType().InvokeMember(

                            "SendCommand", System.Reflection.BindingFlags.InvokeMethod, null, ActiveDocument, dataArry);

                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("FILEDIA", fileDia);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 10:57:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477120#M55394</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-30T10:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477734#M55395</link>
      <description>&lt;P&gt;Many Thanks Hallex, as you've helped me when I was in a pickle before.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having some success here!&amp;nbsp;&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;&lt;/P&gt;&lt;P&gt;It works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two follow-up Questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So why use the&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; ActiveDocument.[GetType]().InvokeMember("SendCommand", System.Reflection.BindingFlags.InvokeMethod, Nothing, ActiveDocument, dataArry)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;instead of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   ActiveDrawing.SendStringToExecute("-linetype load....etc",False,False,False)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Why use the InvokeMember? Does it work faster or better? What's the difference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could I just use:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Public Shared Sub SendCommand(ByVal Command As String)
            Dim doc As Autodesk.AutoCAD.ApplicationServices.Document
            doc = Application.DocumentManager.MdiActiveDocument
            doc.SendStringToExecute(Command, False, False, True)


            
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As my function/method for sending commands? What should I dig into to learn more about this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. &lt;/STRONG&gt;What does LockDocument do exactly, (Yes obviously it locks the document) &lt;STRONG&gt;&lt;U&gt;but why do it on the linetype load&lt;/U&gt;&lt;/STRONG&gt;?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 16:09:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477734#M55395</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-30T16:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477756#M55396</link>
      <description>&lt;P&gt;Oh for anybody following along here's my code;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; &amp;lt;CommandMethod("reloadLinetype", CommandFlags.Session)&amp;gt; _
        Public Shared Sub Reload_LineType()

            ' Set full path of .LIN file herer:
            Dim linfile As String = gstrc_SFR_LineType_FullFileName
            Dim linName As String = "PNEUMATIC"
            Dim bReload As Boolean = False

            '' Get the current document and database
            Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim DB As Database = acDoc.Database

            Try

                'Lock Document
                Using DocLock As DocumentLock = acDoc.LockDocument

                    '' Start a transaction
                    Using TR As Transaction = DB.TransactionManager.StartTransaction

                        '' Open the Linetype table for read
                        Dim acLineTbl As LinetypeTable
                        acLineTbl = TR.GetObject(DB.LinetypeTableId, _
                           OpenMode.ForWrite)

                        If acLineTbl.Has(linName) = true Then
                            bReload = True 
                        End If 

                        ' Save the changes and dispose of the transaction
                        TR.Commit()


                    End Using

                End Using



                Dim fileDia As System.Int16 = CShort(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("FILEDIA"))

                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("FILEDIA", 0)

                'reload using linetype command...

                Dim acadObject As [Object] = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication

                Dim ActiveDocument As Object = acadObject.[GetType]().InvokeMember("ActiveDocument", System.Reflection.BindingFlags.GetProperty, Nothing, acadObject, Nothing)

                Dim dataArry As Object() = New Object(0) {}

                If bReload Then
                    dataArry(0) = "-linetype Load " &amp;amp; linName &amp;amp; vbLf &amp;amp; linfile &amp;amp; vbLf &amp;amp; "Yes" &amp;amp; vbLf &amp;amp; " "
                Else
                    dataArry(0) = "-linetype Load " &amp;amp; linName &amp;amp; vbLf &amp;amp; "acad.lin" &amp;amp; vbLf &amp;amp; " "
                End If

                ActiveDocument.[GetType]().InvokeMember("SendCommand", System.Reflection.BindingFlags.InvokeMethod, Nothing, ActiveDocument, dataArry)

                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("FILEDIA", fileDia)


                dataArry(0) = "regen" &amp;amp; vbLf 
                ActiveDocument.[GetType]().InvokeMember("SendCommand", System.Reflection.BindingFlags.InvokeMethod, Nothing, ActiveDocument, dataArry)
             
           
            Catch
                Console.WriteLine("Error in LoadLineType")
            End Try


        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 16:07:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477756#M55396</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-30T16:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477790#M55397</link>
      <description>&lt;P&gt;In reponse to VB_Autocad_guy...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The InvokeMember() code is calling the COM interop's AcadDocument.SendCommand() method, except it is calling this using&amp;nbsp;the&amp;nbsp;.NET reflection library's&amp;nbsp;late binding technique. You can google this for more details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The AcadDocument.SendCommand() method has the advantage of being executed straight away (i.e. synchronously) versus the Document.SendStringToExecute() method which is executed after your code has finished (i.e. asynchronously).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that&amp;nbsp;for the COM AcadDocument.SendCommand() method to work synchronously it must be called in the application context (i.e. CommandFlags.Session needs to be set).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calling this method using late binding&amp;nbsp;is&amp;nbsp;significantly slower than if you reference the interop dll directly in your project.&amp;nbsp;However the advantage is that it will work for both 32-bit and 64-bit systems as well as different versions of AutoCAD - i.e. you&amp;nbsp;don't have to create multiple builds just for&amp;nbsp;a simple COM interop call every now and then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a nice trick to know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some further&amp;nbsp;background refer to these posts:&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2006/08/techniques_for_.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2006/08/techniques_for_.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2011/11/generating-preview-images-for-all-blocks-in-an-autocad-drawing-using-net.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2011/11/generating-preview-images-for-all-blocks-in-an-autocad-drawing-using-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 16:32:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477790#M55397</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-30T16:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477814#M55398</link>
      <description>&lt;P&gt;Oh and if you are accessing a document from the application context (i.e. CommandFlags.Session) then you need to lock any document before you edit it, hence the DocumentLock.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 16:39:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/3477814#M55398</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-30T16:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reload LineTypes</title>
      <link>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/4342253#M55399</link>
      <description>&lt;P&gt;This example doesn't work with localized AutoCAD. My command enters in an infinite loop and writes messages to command line like "The command "-LINETYPE" doesn't exist".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to write this line correctly in this situation?&lt;/P&gt;&lt;PRE&gt;dataArry[0] = "-linetype Load CENTER\n" + linfile + "\nYes\n ";&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2013 03:13:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/reload-linetypes/m-p/4342253#M55399</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-25T03:13:09Z</dc:date>
    </item>
  </channel>
</rss>

