<?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: Detection of changes made in Autocad/Civil 3D with .NET in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12612377#M5209</link>
    <description>&lt;P&gt;You may want to provide more description on the situation when/why you need to know a point group (or any object, for that matter) is added, modified or deleted. What role the form (your custom UI, obviously) plays in this situation (how the UI is displayed make HUGE difference here: being modeless or modal!), because it seems only the UI need to show the point group information and the potential changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you show the UI as modal (i.e. a Dialog box), then point groups in the drawing CANNOT BE CHANGED/ADDED/DELETED, UNELSS the action is triggered by the UI itself (say, user clicks a button to add/change/delete), therefore, your code knows when the changes occur.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the UI is modeless, then things are quite complicated. You need to handle various events (Entity.ObjectModified, or Database.ObjectAppended/Modified/Erased), or you may try to use ObjectOverrule to monitor the possible changes and decide a proper way to do (or not to do) something once changes are detected. This monitoring/handling work should have nothing to do with your modeless UI, but you probably need to decide whether the UI needs a refresh or not. As I said, it is rather complicated/advanced AutoCAD programming task. Not sure what your skill level is, I just stop here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2024 18:09:29 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2024-03-04T18:09:29Z</dc:date>
    <item>
      <title>Detection of changes made in Autocad/Civil 3D with .NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12611001#M5208</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it to detect and run when I add/remove a point group to Civil3d.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my code only recognizes the groups it sees at startup&amp;nbsp;(while the form is loading) and&amp;nbsp;detects it while working.&lt;/P&gt;&lt;P&gt;It does not recognize groups added/deleted later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Public Class FRM_SampleLineExport&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Dim oPG As Autodesk.Civil.DatabaseServices.PointGroup = Nothing&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Private Sub frm_Load()&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim civilDoc As CivilDocument = CivilApplication.ActiveDocument&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim PointGroupIDs As Autodesk.Civil.DatabaseServices.PointGroupCollection&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PointGroupIDs = civilDoc.PointGroups&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; For Each PointGroupID In PointGroupIDs&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oPG = PointGroupID.GetObject(OpenMode.ForRead)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If oPG.Id.ToString = "" Then&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exit For&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Column7.Items.Add(oPG.Name.ToString)&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AddHandler oPG.Modified, AddressOf ChangePGs&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Next&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; End Sub&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Public Sub ChangePGs(ByVal senderObj As Object, ByVal evtArgs As EventArgs)&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;' When a new point group is added to the file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' When group is deleted from file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; End Sub&lt;/DIV&gt;&lt;DIV&gt;End Class&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 Mar 2024 14:22:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12611001#M5208</guid>
      <dc:creator>cengizincebi</dc:creator>
      <dc:date>2024-03-04T14:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Detection of changes made in Autocad/Civil 3D with .NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12612377#M5209</link>
      <description>&lt;P&gt;You may want to provide more description on the situation when/why you need to know a point group (or any object, for that matter) is added, modified or deleted. What role the form (your custom UI, obviously) plays in this situation (how the UI is displayed make HUGE difference here: being modeless or modal!), because it seems only the UI need to show the point group information and the potential changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you show the UI as modal (i.e. a Dialog box), then point groups in the drawing CANNOT BE CHANGED/ADDED/DELETED, UNELSS the action is triggered by the UI itself (say, user clicks a button to add/change/delete), therefore, your code knows when the changes occur.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the UI is modeless, then things are quite complicated. You need to handle various events (Entity.ObjectModified, or Database.ObjectAppended/Modified/Erased), or you may try to use ObjectOverrule to monitor the possible changes and decide a proper way to do (or not to do) something once changes are detected. This monitoring/handling work should have nothing to do with your modeless UI, but you probably need to decide whether the UI needs a refresh or not. As I said, it is rather complicated/advanced AutoCAD programming task. Not sure what your skill level is, I just stop here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 18:09:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12612377#M5209</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-03-04T18:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Detection of changes made in Autocad/Civil 3D with .NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12619678#M5210</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Norman, thank you very much for your information and lead.&lt;/P&gt;&lt;P&gt;My form modeless :(,&amp;nbsp;I had a manually operated button that did this job.&lt;/P&gt;&lt;P&gt;I don't like modal UI (unless you have to-not friendly to me)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to make something user friendly and automatic.&lt;/P&gt;&lt;P&gt;I just didn't want to redirect the user to the button all the time.&lt;/P&gt;&lt;P&gt;I understand from your notes (I examined the methods) that things are very complicated,&lt;/P&gt;&lt;P&gt;and to avoid wasting any more time I will continue with the button &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if anyone wants to share the solution code &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I wouldn't say no, if I find it, I'll publish it too &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&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>Wed, 06 Mar 2024 10:25:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12619678#M5210</guid>
      <dc:creator>cengizincebi</dc:creator>
      <dc:date>2024-03-06T10:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Detection of changes made in Autocad/Civil 3D with .NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12620559#M5211</link>
      <description>&lt;P&gt;Based on what you described, I assume you want to have a modeless form/PaletteSet to show/monitor current status of PointGroups in drawing. That is, when a PointGroup is added, existing one is modified (name change, for example) or erased; or even the CogoPoints in a group is changed, you want to form view updated automatically. The UI would behave just like Properties window, but only show CogoPoint/PointGroup information. It, of course, can be done with Acad/C3d .NET API, but it is a quite involving task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this type task, it would be very important to structure your solution properly to separate the functionality of the operation. Here is roughly I'd do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create a functional component (one or more classes) that handle the change tracking work&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;add handlers to Database.ObjectAppended/ObjectModified/ObjectErased events&lt;/LI&gt;
&lt;LI&gt;Inside the event handlers, examine the e.DBObject is PointGroup/CogoPoint or not. If yes, save the ObjectId of them into a corresponding collections&lt;/LI&gt;
&lt;LI&gt;When the first affected ObjectId is collected, add handler to Application.Idle event (you probably want to set a flag indicating this idle event handler is set because of affected ObjectId has been collected and waiting for current operation, likely a executing command, to be finished)&lt;/LI&gt;
&lt;LI&gt;Once idle event handler runs, you examine the collected ObjectIds to see which CogoPoint/PointGroup added/modified/erase and organize the updated information into a data model. Then you move the idle event handler&lt;/LI&gt;
&lt;LI&gt;Once the updated information data model is ready, raise a custom event with the data model as event argument&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;2. Build the modeless UI. It would much better to use WPF in MVVM pattern, so, that you can have the ViewModel to subscribe the aforementioned custom event. that is, whenever the tracking component raises its "change" event, the ViewModel would use the data model passed through the event argument to update itself, thus the UI.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, you at least structure the code into 2 separate parts/components (change tracking and change presenting) and the 2 would only loosely couple together with event subscription and the common knowledge for both side is the updated information data model. Thus code modification on either side would have no, or minimum impact to the other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wan to tracking other C3D objects, such as Parcel/Network... things could get event more complicated. For example, ParcelSegment change (adding/modifying/erasing) would not limited to itself, it would also affect one or more Parcels (being added/modified/deleted).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure my description make how much sense to you or not. If not much, you may still have a lot to study up to the task, I am afraid.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:08:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12620559#M5211</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-03-06T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Detection of changes made in Autocad/Civil 3D with .NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12626635#M5212</link>
      <description>&lt;P&gt;Hi Norman,&lt;BR /&gt;I understood your descriptions.&lt;/P&gt;&lt;P&gt;Because, you have summarized it beautifully in a simple and understandable manner &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm an amateur software developer somewhere above entry level and below intermediate level. I am a survey engineer, but I'm interested in coding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, I was going to do a study on the parcels in the future.&lt;BR /&gt;I decided to suspend it for a while &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I will continue the point groups with the refresh button.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will investigate Database.ObjectAppished / ObjectModified / ObjectErased events and examine their usage patterns. After solving-understanding-learning these, I will go back and revise the form.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, if I can, I will share it here.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2024 10:59:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detection-of-changes-made-in-autocad-civil-3d-with-net/m-p/12626635#M5212</guid>
      <dc:creator>cengizincebi</dc:creator>
      <dc:date>2024-03-08T10:59:32Z</dc:date>
    </item>
  </channel>
</rss>

