<?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: Update insulation thickness, insulation type and service via .NET API using PnPTable P3dLineGroup in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13074505#M2356</link>
    <description>&lt;P&gt;Hi, I was referring to any DWG file. But today I made a breakthrough.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It turns out that when I finish executing my method that changes these properties for the LineGroupId, if I close the DWG file without saving, and open it again later, it apparently corrupts the file, I believe it must be because the information does not match the of the database.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Currently, I placed it at the end of my method, to save the file, so I didn't have any more problems. However, it would not be ideal for me to always save the file at the end, as the user will not always want to save.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Oct 2024 16:25:17 GMT</pubDate>
    <dc:creator>eduardo_salvador02</dc:creator>
    <dc:date>2024-10-09T16:25:17Z</dc:date>
    <item>
      <title>Update insulation thickness, insulation type and service via .NET API using PnPTable P3dLineGroup</title>
      <link>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13072390#M2354</link>
      <description>&lt;P&gt;Hello, I'm trying to update 3 specific properties via the .NET API for Plant 3D 2025. However, I'm having some problems, when executing my method that updates the lineGroupId with the new properties for the first time in the file, it works very well, the problem is that , if I close the file after running, and open it again and try to run it again or even trace a pipe using "RoutePipe", it gives an error when adding the objects related to the Pipe.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;One of the most common errors I saw: Cannot create a part record in the project database.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can anyone identify what my error is in this method below?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void ApplyPipeSettingsToAllObjects(ObjectId pipeId, Dictionary&amp;lt;string, string&amp;gt; pipeSettings, DataLinksManager dlm, Database db, Editor ed)
{
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        try
        {
            if (pipeId != ObjectId.Null)
            {
                if (pipeId.IsErased)
                {
                    return;
                }

                Pipe pipe = tr.GetObject(pipeId, OpenMode.ForRead) as Pipe;
                PipeInlineAsset pipeInlineAsset = tr.GetObject(pipeId, OpenMode.ForRead) as PipeInlineAsset;

                if (pipe == null &amp;amp;&amp;amp; pipeInlineAsset == null)
                {
                    return;
                }

                if (pipe != null || pipeInlineAsset != null)
                {
                    try
                    {
                        int rowId = dlm.FindAcPpRowId(pipeId);

                        if (rowId == -1)
                        {
                            ed.WriteMessage("\nrowId inválido. Não foi possível associar o pipe ao grupo.");
                            return;
                        }

                        PnPDatabase db1 = dlm.GetPnPDatabase();
                        PnPTable tbl = db1.Tables["P3dLineGroup"];

                        PnPRowIdArray lineGroupId = dlm.GetRelatedRowIds("P3dLineGroupPartRelationship", "Part", rowId, "LineGroup");

                        if (lineGroupId == null || lineGroupId.Count == 0)
                        {
                            ed.WriteMessage("\nNenhum grupo de linha relacionado encontrado.");
                            return;
                        }

                        int lineGroupRowId = lineGroupId.First.Value;

                        if (modifiedLineGroupIds.Contains(lineGroupRowId))
                        {
                            return;
                        }

                        string sStatement = "PnPID=" + lineGroupRowId;
                        PnPRow[] rows = tbl.Select(sStatement);

                        if (rows.Length &amp;gt; 0)
                        {
                            foreach (PnPRow Row in rows)
                            {
                                string newInsulationThickness = pipeSettings.ContainsKey("Isolamento") ? pipeSettings["Isolamento"] : string.Empty;
                                string newInsulationType = pipeSettings.ContainsKey("TipIsolamento") ? pipeSettings["TipIsolamento"] : string.Empty;
                                string newService = pipeSettings.ContainsKey("Service") ? pipeSettings["Service"] : string.Empty;

                                bool rowChanged = false;

                                try
                                {
                                    Row.BeginEdit();

                                    if (Row["InsulationThickness"] != null &amp;amp;&amp;amp; !string.IsNullOrEmpty(newInsulationThickness) &amp;amp;&amp;amp; Row["InsulationThickness"] != newInsulationThickness)
                                    {
                                        Row.SetPropertyValue("InsulationThickness", newInsulationThickness);
                                        rowChanged = true;
                                    }

                                    if (Row["InsulationType"] != null &amp;amp;&amp;amp; !string.IsNullOrEmpty(newInsulationType) &amp;amp;&amp;amp; Row["InsulationType"] != newInsulationType)
                                    {
                                        Row.SetPropertyValue("InsulationType", newInsulationType);
                                        rowChanged = true;
                                    }

                                    if (Row["Service"] != null &amp;amp;&amp;amp; !string.IsNullOrEmpty(newService) &amp;amp;&amp;amp; Row["Service"] != newService)
                                    {
                                        Row.SetPropertyValue("Service", newService);
                                        rowChanged = true;
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    MessageBox.Show($"Erro ao tentar atualizar InsulationThickness, InsulationType e Service.\nErro: {ex}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                finally
                                {
                                    if (rowChanged)
                                    {
                                        Row.EndEdit();
                                    }
                                    else
                                    {
                                        Row.CancelEdit();
                                    }
                                }
                            }

                            try
                            {
                                dlm.AcceptChanges();
                            }
                            catch (System.Exception ex)
                            {
                                ed.WriteMessage($"\nErro ao aplicar mudanças no DataLinksManager: {ex.Message}\n");
                            }

                            if (!modifiedLineGroupIds.Contains(lineGroupRowId))
                            {
                                modifiedLineGroupIds.Add(lineGroupRowId);
                            }
                        }
                        else
                        {
                            ed.WriteMessage("\nNenhuma linha encontrada na tabela P3dLineGroup.");
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show($"Erro ao tentar atualizar InsulationThickness e InsulationType: {ex}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            tr.Commit();
        }
        catch (System.Exception ex)
        {
            tr.Abort();
            MessageBox.Show($"Ocorreu um erro inesperado ao tentar setar as propriedades para o objeto Pipe.\nErro: {ex}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Oct 2024 18:10:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13072390#M2354</guid>
      <dc:creator>eduardo_salvador02</dc:creator>
      <dc:date>2024-10-08T18:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update insulation thickness, insulation type and service via .NET API using PnPTable P3dLineGroup</title>
      <link>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13074283#M2355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14822335"&gt;@eduardo_salvador02&lt;/a&gt;&amp;nbsp;, can you please expand on what file are you talking about when you said &lt;EM&gt;"&amp;nbsp;if I close the file after running, and open it again and try to run it again".&amp;nbsp;&lt;/EM&gt;Can you please expand more on the issue so I can communicate with the Plant team...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 14:37:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13074283#M2355</guid>
      <dc:creator>sreeparna_mandal</dc:creator>
      <dc:date>2024-10-09T14:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Update insulation thickness, insulation type and service via .NET API using PnPTable P3dLineGroup</title>
      <link>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13074505#M2356</link>
      <description>&lt;P&gt;Hi, I was referring to any DWG file. But today I made a breakthrough.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It turns out that when I finish executing my method that changes these properties for the LineGroupId, if I close the DWG file without saving, and open it again later, it apparently corrupts the file, I believe it must be because the information does not match the of the database.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Currently, I placed it at the end of my method, to save the file, so I didn't have any more problems. However, it would not be ideal for me to always save the file at the end, as the user will not always want to save.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 16:25:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/update-insulation-thickness-insulation-type-and-service-via-net/m-p/13074505#M2356</guid>
      <dc:creator>eduardo_salvador02</dc:creator>
      <dc:date>2024-10-09T16:25:17Z</dc:date>
    </item>
  </channel>
</rss>

