Form.AddEdge method

Form.AddEdge method

Anonymous
Not applicable
783 Views
7 Replies
Message 1 of 8

Form.AddEdge method

Anonymous
Not applicable

Hi!

 

I am kind of new in the Revit API, and i have been really struggling with a problem. I did a loft (form) between 2 profiles, but the loft is not the way I want it too, so I need to add edges to correct it. 

However, I can´t execute the method to add edges (Form.AddEdge) - the inputs are the geometry references of 2 points - because I can´t get the reference of a point. I tried to create reference points, and then create the Reference of the reference points but I get the error : "It should be a reference of point in the form.".

 

 

Did anyone already used the Form.AddEdge method?

 

Thanks!!

0 Likes
784 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Dear Aafm92,

 

I have never used that method myself.

 

However, just reading the Revit API help file RevitAPI.chm, I see some hints.

 

You have installed that file and placed a shortcut on your desktop, heven't you? 

 

Have you taken a look at the method overloads yet?

 

If not, please do so right now.

 

I see three overloads taking references, XYZ points, and edge parameter data.

 

The references must come from the form itself.

 

To retrieve such a reference, you may be able to 

 

  • Create the form
  • Regenerate the model
  • Query the form geometry via the Element.Geometry property with options ComputeReferences = true

 

Aternatively, you can just specify the XYZ point coordinates.

 

That might be simpler.

 

I hope this helps.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 8

Anonymous
Not applicable

Dear Jeremy,

 

Thanks for the answer, I really appreciate it. 

In the end of the answer you say:

 

"Aternatively, you can just specify the XYZ point coordinates.

 

That might be simpler."

 

I have the XYZ variables specified, but none of the Form.AddEdges overloads creates an edge specifying just 2 points.

 

Again, thanks for the help.

0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Right you are. Sorry, I misread the description. I thought it took two XYZ arguments. Now I see that it is one reference and one XYZ...



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 8

Anonymous
Not applicable

Dear Jeremy,

 

I tried to use the Form.AddEdge method with the overload:

 

Form.AddEge (Reference startEdgeReference, Double startParam, Reference endEdgeReference, Double endParam)  

 

To do this, I extracted the edges of my form, which were then used in the method. Here's part of the code:

 

                Options opt = new Options();

 

                opt.ComputeReferences = true;

 

                GeometryElement geoElement = loftform.get_Geometry(opt);

 

                Solid solido = geoElement.First() as Solid;

 

                EdgeArray edge = solido.Edges;

 

                Edge edge1 = edge.get_Item(1);

                Edge edge2 = edge.get_Item(2);

                Edge edge3 = edge.get_Item(3);

                Edge edge4 = edge.get_Item(4);

                Edge edge5 = edge.get_Item(5);

                Edge edge6 = edge.get_Item(6);

                Edge edge7 = edge.get_Item(7);

                Edge edge8 = edge.get_Item(8);

                Edge edge9 = edge.get_Item(9);

                Edge edge10 = edge.get_Item(10);

                Edge edge11 = edge.get_Item(11);

 

                loftform.AddEdge(edge1.Reference, 1, edge3.Reference, 0);

                loftform.AddEdge(edge4.Reference, 0, edge3.Reference, 1);

                loftform.AddEdge(edge4.Reference, 0, edge6.Reference, 1);

                loftform.AddEdge(edge7.Reference, 0, edge9.Reference, 0);

                loftform.AddEdge(edge7.Reference, 0, edge9.Reference, 1);

                loftform.AddEdge(edge10.Reference, 0, edge11.Reference, 0);

                loftform.AddEdge(edge10.Reference, 0, edge11.Reference, 1);

                loftform.AddEdge(edge11.Reference, 1, edge10.Reference, 1);

 

                doc.Regenerate();

 

However, I execute the code, don't get any error, but the form stays the same. 

Do you have any hint on this? 

 

Thanks again for your help.

 

0 Likes
Message 6 of 8

jeremytammik
Autodesk
Autodesk

How do you know that 0 and 1 are the right parameters along the curve?

 

The parametrisation can be pretty arbitrary, can't it?

 

Maybe it will help to query the curve for its parametrisation, e.g. retrieve the start and end paramter values and use those.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 8

Anonymous
Not applicable

I solved the problem. Here's part of the code:

 

Options opt = new Options();

opt.ComputeReferences = true;

GeometryElement geoElement = loftform.get_Geometry(opt);

Solid solido = geoElement.First() as Solid;

EdgeArray edge = solido.Edges;

Edge edge1 = edge.get_Item(1);

// Curve edge1_curve = edge1.AsCurve();

Edge edge2 = edge.get_Item(2);
Edge edge3 = edge.get_Item(3);
Edge edge4 = edge.get_Item(4);
Edge edge5 = edge.get_Item(5);
Edge edge6 = edge.get_Item(6);
Edge edge7 = edge.get_Item(7);
Edge edge8 = edge.get_Item(8);
Edge edge9 = edge.get_Item(9);
Edge edge10 = edge.get_Item(10);
Edge edge11 = edge.get_Item(11);

//loftform.AddEdge(edge3.GetEndPointReference(1), edge1.GetEndPointReference(0));


loftform.GetControlPoints(edge3.Reference).get_Item(0);


loftform.GetControlPoints(edge3.Reference).get_Item(0);

loftform.AddEdge(loftform.GetControlPoints(edge3.Reference).get_Item(1), loftform.GetControlPoints(edge1.Reference).get_Item(0));
loftform.AddEdge(loftform.GetControlPoints(edge6.Reference).get_Item(1), loftform.GetControlPoints(edge4.Reference).get_Item(0));
loftform.AddEdge(loftform.GetControlPoints(edge9.Reference).get_Item(0), loftform.GetControlPoints(edge7.Reference).get_Item(0));
loftform.AddEdge(loftform.GetControlPoints(edge11.Reference).get_Item(1), loftform.GetControlPoints(edge10.Reference).get_Item(0));

 

0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

Cool! 

 

Congratulations!

 

Would you like to add a picture or two so we understand better what you achieved, and possibly a sample model and a zipped version of the entire add-in source code and solution file, in case anyone else would like to try to reproduce this?

 

Thank you!



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes