Autodesk / civilconnection

CivilConnection enables the exchange of information between Civil 3D, Dynamo and Revit.
94 stars 43 forks source link

GetPointGroups error #35

Closed EduardLouis closed 4 years ago

EduardLouis commented 4 years ago

Which version are you using? we have our internal version, but is base on your version 4.0.4 What did you do? (Steps to reproduce)

_1. Open a new Civil3D file

  1. Add a point group from Dynamo
  2. Read the points groups => works fine
  3. Go to Civil3D, delete all poins from document
  4. Read the points group => no points in document, empty list => works fine
  5. Add a new point group form Dynamo
  6. Read the points groups => didn't works_

What did you expect to happen? To get the current points from Civil3D file.

What did happen instead? return an error: The parameter is incorrect.

The points are read from document by index in points list, but the provided number as index represent the point number not the index. The actual solution works fine only if no point is deleted because only in this case the index == point number.

dynamo defintiion cogo points.zip

solution:

change the below line https://github.com/Autodesk/civilconnection/blob/42018c93d3142dcfcbbaca966420e89d56172d83/Src/CivilConnection/2020/Autodesk2020/Utils.cs#L474

with: AeccPoint p = doc.Points.Find(i);

EduardLouis commented 4 years ago

About the COGO Points is useful to have option to replace the points in the existing groups. It's a little bit confusing when work with point groups from Dynamo because always the points are appended to the existing groups and it's difficult to track the points in Dynamo.

If we create already some points in a group and run again the script from the starting point, is expected that the points from the groups to be deleted and create the new ones. Or to go more deep, to be checked the existing points in Civil3D if them are the same with the dynamo points. The last solution take more time to run than deleting and making again the points.

We take a new input from Dynamo, deleteExistingPoints and base on this we detele or not the existing points in the groups.

                if (group == null)
                {
                    group = groups.Add(name);
                }
                else
                {
                    if (group.PointCount > 0 && deleteExistingPoints == true)
                    {
                        foreach (int i in group.Points)
                        {
                            AeccPoint p = doc.Points.Find(i);
                            doc.Points.Remove(p.Number);
                        }
                    }
                }

and

                if ("" == formula || deleteExistingPoints == true)
                {
                    formula = numbers[0] + "-" + numbers[numbers.Count - 1];
                }
                else
                {
                    formula += ", " + numbers[0] + "-" + numbers[numbers.Count - 1];
                }