Autodesk / civilconnection

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

CivilConnection not work in family environment #16

Closed EduardLouis closed 4 years ago

EduardLouis commented 4 years ago

Hi Paolo,

If we run CivilConnection on family environment is not working. Can be made an workaround if is run it in a family environment to set the cs in 0,0,0?

image image

paoloemilioserra commented 4 years ago

@EduardLouis at first I'd say no, but can you please elaborate on the workflow you have in mind?

EduardLouis commented 4 years ago

It's the same workflow as exporting geometry in a mass family, but we use parametric profiles to generate the geometry. In Civil3D we have only the road corridors, without geometry of the structure and base on it we place parametric profiles along the roads and create lofts. => if the structure is changed, this can be very easy changed by any Revit user without any deep knowledge of Revit or Dynamo. => if the road is changed, we update with a script the profile position to fallow the road. For us is more convenient to work in this way because in the project stage where we are involved are vary many changes weekly.

paoloemilioserra commented 4 years ago

@EduardLouis, the Family Document doesn't have the notion of the Total Transform you have in the Project Document, this is necessary to have the Civil geometries dealt with correctly in Revit, without it you need to pass an object that replicates the Shared Site that you have in the Revit project. FOr simplicity all the families that are generated in CivilConnection share the same local origin as the project in which they are going to be used. I don't want the user to type manually the coordinates of the project, so we'll need to figure out a way to support multiple Revit document (project/families) in Dynamo which as you know it is not available by design.

EduardLouis commented 4 years ago

I know is not possible. I have to know where I will use that family before to create it. For that, I store the site location of the Revit project in a Civil3D file and when I run the CivilConnection in a family I read that location. For me was most easy way to make the transition of the coordinates form the project in the family. Now I thinking about a more elegant solution, to have a pop-up dialog where to select the Revit file where the family is loaded. If we have the revit file, the document of the file can be read and the location to be extracted. If no file is selected, CivilConnection can return null.

Lazarica-t commented 4 years ago

Hi @paoloemilioserra I can confirm this issue is present in the latest version of CivilConnection2019 4.0.4 when running the node CivilApplication.CivilApplication in a Generic Family, in a project it seams to run ok. For CivilConnection2018 and CivilConnection2020 same thing.

image

With version 3.0.8 the issue is not present: image

EduardLouis commented 4 years ago

Hi again,

For me it's working fine with this small change, on RevitUtils.cs, inserted on lin 676:

if (location == null)
                {
                    try
                    {
                        OpenFileDialog file = new OpenFileDialog();
                        //Allow to select multiple files
                        file.Multiselect = false;

                        //Allow to select only *.txt Files
                        file.Filter = "Only Revit Project Documents | *.rvt";

                        //Set the title
                        file.Title = "Select the reference Revit project for the WIP family.";
                        //Show the Dialog box to selcet file(s)
                        file.RestoreDirectory = true;
                        file.ShowDialog();
                        //return input file names

                        string fullName = file.FileName;

                        var tempRVTDoc = doc.Application.OpenDocumentFile(fullName);
                        location = tempRVTDoc.ActiveProjectLocation;
                        var transform = location.GetTotalTransform();

                        cs = CoordinateSystem.ByOriginVectors(transform.Origin.ToPoint(), transform.BasisX.ToVector(), transform.BasisY.ToVector(), transform.BasisZ.ToVector());

                        SessionVariables.DocumentTotalTransform = cs;
                        tempRVTDoc.Close(false);
                        Utils.Log(string.Format("RevitUtils.DocumentTotalTransform - location read from {0}", fullName));
                    }
                    catch
                    {

                    }
                }
                else
                {

                    var transform = location.GetTotalTransform();

                    cs = CoordinateSystem.ByOriginVectors(transform.Origin.ToPoint(), transform.BasisX.ToVector(), transform.BasisY.ToVector(), transform.BasisZ.ToVector());

                    SessionVariables.DocumentTotalTransform = cs;
                }

I'm not sure what happen if the revit project is saved on BIM360, or if is central model, or have errors at opening... it's just a proof of concept.

paoloemilioserra commented 4 years ago

Not going to implement.

EduardLouis commented 4 years ago

Not going to implement.

What about more simple solution: if doc.IsFamilyDocument == True => Utils.Log(string.Format("RevitUtils.DocumentTotalTransform is NULL in a family enviroment.", "")) and return cs = null

Lazarica-t commented 4 years ago

@EduardLouis, ...so we'll need to figure out a way to support multiple Revit document (project/families) in Dynamo which as you know it is not available by design.

@paoloemilioserra I understand why you would want to make life easier for the user, but as @EduardLouis is suggesting, I think it would be wise and much more helpful for us to have the option to use CivilConnection in a family environment, at least until there is a new solution available!

Best regards!

paoloemilioserra commented 4 years ago

@Lazarica-t CivilConnection is not going to be used in a family Document, you are free to create and maintain your own nodes.

Lazarica-t commented 4 years ago

Thank you for your support @paoloemilioserra!