<?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 Struggling with Alignment.CopyToSite() method with .NET on Python in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9400220#M8590</link>
    <description>&lt;P&gt;Hello and thank you for the attention.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Dynamo for Civil 3D's Python Script. There I started working on some rutines successfully. Now, trying to copy an alignment I found that CopyToSite() method does not work properly. I mean, apparently it doesn't follow any rules. Sometimes it works and when it works is weird because mostly those times I enter CopyToSite("SampleSite") and it generates a siteless alignment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very confused and curious. ¿Could anyone help me?&amp;nbsp;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.dwg and .dyn attached&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;I tried with all parameters possible (''), ('string'), (None) or (ObjectId)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;Using Civil 3D 2020&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2020 19:30:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-25T19:30:10Z</dc:date>
    <item>
      <title>Struggling with Alignment.CopyToSite() method with .NET on Python</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9400220#M8590</link>
      <description>&lt;P&gt;Hello and thank you for the attention.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Dynamo for Civil 3D's Python Script. There I started working on some rutines successfully. Now, trying to copy an alignment I found that CopyToSite() method does not work properly. I mean, apparently it doesn't follow any rules. Sometimes it works and when it works is weird because mostly those times I enter CopyToSite("SampleSite") and it generates a siteless alignment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very confused and curious. ¿Could anyone help me?&amp;nbsp;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.dwg and .dyn attached&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;I tried with all parameters possible (''), ('string'), (None) or (ObjectId)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;Using Civil 3D 2020&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 19:30:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9400220#M8590</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-25T19:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with Alignment.CopyToSite() method with .NET on Python</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9402612#M8591</link>
      <description>This is all new to me so it took a bit to figure out how to even use the script. Now that I've got that worked out, I'm seeing that CopyToSite will only work with SitelessAlignments. Trying to copy a siteless alignment to a Site results in a new Siteless alignment. Trying to copy an alignment in a Site results in no new alignment.&lt;BR /&gt;&lt;BR /&gt;Strange thing is that the CopyToSite works fine when used in a typical .NET assembly (created in VS c#). Why it's failing to work in Python, I have no idea.</description>
      <pubDate>Thu, 26 Mar 2020 18:28:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9402612#M8591</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2020-03-26T18:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with Alignment.CopyToSite() method with .NET on Python</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403053#M8592</link>
      <description>&lt;P&gt;For testing, I simplified the code to:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sitename = IN[0]
doc = acapp.DocumentManager.MdiActiveDocument
with doc.LockDocument():
	with doc.Database.TransactionManager.StartTransaction() as t:
		for id in CivilApplication.ActiveDocument.GetAlignmentIds():
			al = t.GetObject(id, OpenMode.ForRead)
			al.CopyToSite(sitename)
		t.Commit()
OUT = True&lt;/LI-CODE&gt;&lt;P&gt;Run this code and the alignments are all copied to the named site ... eventually. There is some sort of lazy execution happening here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The alignments are immediately copied as siteless alignments and appear in the Alignments &amp;gt; Centerline Alignments node. Then, after some time, they are moved to the Site node. This might simply be a toolspace refresh delay issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to make this above code act more predictably by appending a REGEN execution after the commit (but this might just be some sort of confirmation bias in my testing).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import System
# ...
app = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application")
AcDoc = app.ActiveDocument
AcDoc.SendCommand('REGEN ')&lt;/LI-CODE&gt;&lt;P&gt;I was only able to get your code to work if a site name was specified and the REGEN command was sent after the&amp;nbsp; &lt;SPAN&gt;TramoCorridor method executed.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 21:46:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403053#M8592</guid>
      <dc:creator>tyronebk</dc:creator>
      <dc:date>2020-03-26T21:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with Alignment.CopyToSite() method with .NET on Python</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403767#M8593</link>
      <description>&lt;P&gt;Thanks a lot for the attention and time spent. Hope that getting into Dynamo's Python was at least, a new expirience so we both learn&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 09:06:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403767#M8593</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-27T09:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with Alignment.CopyToSite() method with .NET on Python</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403776#M8594</link>
      <description>&lt;P&gt;YEAH, that's right! Thank you very much. That solution ('REGEN') is working well.&amp;nbsp; You defined the problem and solution with accuracy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the time spent&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 09:10:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/struggling-with-alignment-copytosite-method-with-net-on-python/m-p/9403776#M8594</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-27T09:10:57Z</dc:date>
    </item>
  </channel>
</rss>

