XData not showing up for pipe segment

I am trying to extract all material from CADWorx models. I am on a trial right now to make sure everything works as expected before purchase. I noticed that on pipe segments its not loading the XData for CPD1. You can see it in autoCAD with XDLIST, I will attach a file for refference

  • Registered Application Name: CPD1
  • Code 1002, Starting or ending brace: {
  • Code 1000, ASCII string: 3"
  • Code 1000, ASCII string: PIPE
  • Code 1000, ASCII string: PIPE SMLS SCH 80 A106-B
  • Code 1000, ASCII string: 3-WP-0801-A15-1ETW
  • Code 1000, ASCII string:
  • Code 1000, ASCII string: 3DD
  • Code 1000, ASCII string: 1T
  • Code 1000, ASCII string: (“_A15” “Project.prj” “SMLS_ASME_B36.10M”)
  • Code 1000, ASCII string: (“PIPW” 3.0000 3.5000)
  • Code 1000, ASCII string:
  • Code 1040, Real number: 6 7/16"
  • Code 1040, Real number: 10 1/4"
  • Code 1040, Real number: 5/16"
  • Code 1040, Real number: 5/16"
  • Code 1070, 16-bit integer: 515
  • Code 1070, 16-bit integer: 1

@dvest

It seems you’re experiencing difficulties extracting XData for the CPD1 registered application from CADWorx models. If the XData for pipe segments is not loading as expected, this could be due to several factors, including the specific configuration of the CADWorx model or the method of data access.

To troubleshoot this issue, consider the following steps:

  1. Check Model Configuration: Verify that the pipe segments in your CADWorx model are properly configured to include the XData you are attempting to extract.

  2. Use Aspose.CAD: Ensure you are utilizing the correct methods in Aspose.CAD to access XData. Refer to the Aspose.CAD documentation for guidance on extracting XData from CAD files.

  3. Debugging: Implement logging to identify if the extraction process is encountering errors or if the data is simply absent in the model.

  4. Sample Code: Here’s a basic example to help you get started with extracting XData:

    using Aspose.CAD;
    using Aspose.CAD.FileFormats.Cad;
    
    // Load the CAD file
    using (var cadImage = CadImage.Load("path_to_your_file.dwg"))
    {
        // Access the entities and extract XData
        foreach (var entity in cadImage.Entities)
        {
            if (entity.XData != null)
            {
                // Process the XData
                Console.WriteLine(entity.XData);
            }
        }
    }
    

If the issue persists, consider reaching out to Aspose support for more specific guidance related to your CADWorx models.

Feel free to ask if you have any further questions!

Here is the file, its just a single pipe segment I was using to try and figure out why its not pulling, thanks!
Example.zip (173.1 KB)

The current version CadImage does not have .Entities. Here is the code

foreach (string file in Directory.EnumerateFiles(folderPath, “*.dwg”, SearchOption.AllDirectories))
{

 // Start timer for individual file
 Stopwatch fileTimer = Stopwatch.StartNew();
 int fileEntityCount = 0;
 totalFileCount++;

 try
 {


     using (var cadImage = (CadImage)Image.Load(file))
     {
         List<CadBlockEntity> tableBlocks = new List<CadBlockEntity>();
         var entitys = cadImage.BlockEntities?.ValuesTyped;
         if (entitys == null)
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.WriteLine("Error: No block entities found in " + file);
             Console.ResetColor();
             continue;
         }

         foreach (CadBlockEntity entity in entitys)
         {
             if (entity?.Name.StartsWith("*Model_Space") == true)
             {
                 tableBlocks.Add(entity);
             }
         }

         if (tableBlocks.Count > 0)
         {
             Console.ForegroundColor = ConsoleColor.Green;
             Console.WriteLine("Processing: " + file);
             Console.ResetColor();
             Console.WriteLine();

             var textElements = tableBlocks[0].Entities;
             if (textElements != null)
             {
                 foreach (var entity in textElements)
                 {
                     fileEntityCount++;
                     totalEntityCount++;

                     Console.WriteLine("ObjectId - " + entity.Id + " : " + entity.LayerName + " - #" + cnt);
                     cnt++;

                     if (entity.XdataContainer?.Xdatas != null)
                     {
                         CadXdata cpd1 = entity.XdataContainer.GetData("CPD1");

                         if (cpd1 != null)
                         {
                             string entityId = entity.Id;
                             string size = cpd1.DataList[1].Value.ToString();
                             string type = cpd1.DataList[2].Value.ToString();
                             string description = cpd1.DataList[3].Value.ToString();
                             string lineNo = cpd1.DataList[4].Value.ToString();
                             string tagNo = cpd1.DataList[10].Value.ToString();
                             string length = cpd1.DataList[11].Value.ToString();
                         }

                         //foreach (CadXdata xdata in entity.XdataContainer.Xdatas)
                         //{
                         //    Console.ForegroundColor = ConsoleColor.Cyan;
                         //    Console.WriteLine("XData Name: " + xdata.Name);
                         //    Console.ResetColor();
                         //    if (xdata.DataList != null)
                         //    {
                         //        if (xdata.Name == "CPD1")
                         //        {
                         //            string check = xdata.DataList[3].Value.ToString();
                         //        }

                         //        foreach (CadCodeValue item in xdata.DataList)
                         //        {
                         //            Console.WriteLine(item.Attribute + " : " + item.Value);
                         //        }
                         //    }
                         //    Console.WriteLine();
                         //}
                     }

                     Console.WriteLine();
                 }
             }
         }
     }
 }
 catch (Exception ex)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine("Error: " + file + " - " + ex.Message);
     Console.ResetColor();
 }

 // Stop file timer and output results
 fileTimer.Stop();
 Console.ForegroundColor = ConsoleColor.Yellow;
 Console.WriteLine($"File: {file}");
 Console.WriteLine($"Entities Processed: {fileEntityCount}");
 Console.WriteLine($"Time Taken: {fileTimer.Elapsed.TotalSeconds:F2} seconds");
 Console.WriteLine();
 Console.ResetColor();

}

@dvest,
Hi,
thank you for all details, we have created CADNET-10266 ticket to investigate this case.

1 Like

Thank you, looking forward to getting this resolved. This product could do some big this for our company but we have to be able to trust the output.

Some more info for the developers, we are using the .Net 4.8 version based on the software requirements I am working with to build this addin.

@dvest,
thank you for details, sure, we always encourage customers to verify everything before the purchase. I have notes the .NET version in the task and will come bask with more details on it as soon as I have it.

1 Like