NewAligment between inclined reference and a point

NewAligment between inclined reference and a point

Speed_CAD
Collaborator Collaborator
802 Views
8 Replies
Message 1 of 9

NewAligment between inclined reference and a point

Speed_CAD
Collaborator
Collaborator

Hi,

 

From the Revit UI I can align a point with a slanted reference and lock it, as I show in the image sequence, however from the API I have not been able to create the constraint, the error is 'The two references are not geometrically aligned so the Alignment cannot be created.
Parameter name: reference2'

 

I created the reference2 variable with ParseFromStableRepresentation from GetEndPointReference(0).ConvertToStableRepresentation(doc), the stable String is the same as what RevitLookup shows when I check the constraint from the user interface, but it doesn't work from the API.

 

What could be the error?

 

Inclined referenceInclined referencePointPointConstraintConstraint

Mauricio Jorquera
0 Likes
Accepted solutions (2)
803 Views
8 Replies
Replies (8)
Message 2 of 9

jeremy_tammik
Alumni
Alumni

Did you note the remarks in the documentation on the NewAlignment method?

  

https://www.revitapidocs.com/2024/b3c10008-aba6-9eee-99c9-7e05ace75796.htm

  

It clearly states:

  

> Remarks: ... These references must be already geometrically aligned (this function will not force them to become aligned).

  

Did you ensure the exact element alignment before calling the method?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 9

Speed_CAD
Collaborator
Collaborator

Hi Jeremy,

 

Thanks for answering. Yes, I know the method and I have already used it to align other elements without problems. What I am trying to align are not parallel or perpendicular elements, as seen in the images, but from the user interface it is possible to do it, and the premise is that if it can be done from the interface it can be done from the API. But in this particular case, how should the elements be aligned for it to work?, since the line is vertical and the edge is inclined.

 

Is it necessary to first modify the point of the line and make it reach the inclined face and then apply the method? This is what needs to be done for other types of alignments, but in this case I don't know.

 

Thank you

Mauricio Jorquera
0 Likes
Message 4 of 9

jeremy_tammik
Alumni
Alumni
Accepted solution

Dear Mauricio,

  

Thank you for the clarification. It is possible that the API does not provide support for the full UI functionality in this specific case. Again, from the remarks in the documentation: 

   

These two references must be one of the following combinations:

   

  •  2 planar faces
  • planar face and reference plane
  • 2 lines
  • line and point
  • line and reference plane
  • 2 arcs
  • 2 cylindrical faces

  

If worst comes to worst, you can implement an updater to ensure the required alignment, as demonstrated by the DynamicModelUpdate SDK sample.

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 9

RPTHOMAS108
Mentor
Mentor

Firstly what are the elements in question model/detail lines or geometry from other elements?

 

If they are lines you may find that Revit can't avoid joining them regardless, so you don't need the alignment. Refer to CurveElement.SetGeometryCurve overrideJoins for example.

 

Otherwise try finding the intersection adjusting the line to that intersection and then using NewAlignment.

0 Likes
Message 6 of 9

Speed_CAD
Collaborator
Collaborator

Hi Jeremy,

 

I had thought about implementing an updater but the line should not always be aligned with the tilted face when modifying the face, this decision is made by the end user by activating the option in a configuration dialog.

Mauricio Jorquera
0 Likes
Message 7 of 9

Speed_CAD
Collaborator
Collaborator

Hi RPTHOMAS108,

 

The elements in question are a Detail Item line based family and the face of a Floor.

 

The alignment that Revit does when I do it through the user interface results in surface and linear type references, the linear reference seems to me to use the Reference Line that exists in the Detail Item line based family.

 

The Stable Strings are:
ce10c175-2d94-453e-8453-e029f5e5a40f-000192a8:85:SURFACE (for the face of the Floor).
da837083-6602-42a1-9ee7-49e331345597-0007821e:0:INSTANCE:da837083-6602-42a1-9ee7-49e331345597-00078410:9:LINEAR/0 (for linear family reference).

 

From the API I obtained the same strings from which I created the references with Reference.ParseFromStableRepresentation, I modified the starting point of the family so that it coincides with the face of the floor and then I applied the NewAlignment method, but it still shows the same error.

Mauricio Jorquera
0 Likes
Message 8 of 9

RPTHOMAS108
Mentor
Mentor
Accepted solution

Face of floor will be surface reference and the point/surface alignment isn't listed above as one of the possibilities for this API.

0 Likes
Message 9 of 9

Speed_CAD
Collaborator
Collaborator

Thanks RPTHOMAS108,

 

Apparently it is as you say. I will have to give it another approach, perhaps the idea that Jeremy raised.

Mauricio Jorquera
0 Likes