New Alignment Method does not work

New Alignment Method does not work

Anonymous
Not applicable
2,608 Views
11 Replies
Message 1 of 12

New Alignment Method does not work

Anonymous
Not applicable

Hi all,

 

I´m working with the NewFamilyInstance method, using Lines (to create FamilyInstances) and Face (To rotate and place correctly). That works perfectly. But I have problems in some scenarios, for example, the host that has a slope.

 

I would need to correct the alignment, getting a new face as a reference, similar to use Align function in Revit.

 

This is my code, I didn`t have any description of the problem, just the line that causes the exception.

 

  Reference reference3 = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Face, "Select Face 1");
  Reference reference4 = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Face, "Select Face 2");
           
            using (Transaction transaction = new Transaction(doc, "Align"))
            {
                transaction.Start();
doc.Create.NewAlignment(doc.ActiveView, reference3, reference4); transaction.Commit(); }

1.png

0 Likes
2,609 Views
11 Replies
Replies (11)
Message 2 of 12

jeremytammik
Autodesk
Autodesk

What is your question, please?

 

What exception is thrown?

 

The elements you wish to create an alignment constraint for must be pre-aligned before you create the alignment, i.e., you have to position them precisely yourself before creating the alignment.

 

RTFM:

 

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

 

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

 

Please be aware of that.

 

May be that is throwing the exception?



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

Message 3 of 12

Anonymous
Not applicable

Hi Jeremy, 

 

I created the elements and they are already geometrically aligned. Also I tried with the combinations described on the documentation. (two planar faces, 2 lines and lines and point). I tried with other elements as Reference, like walls.

 

The exception just says the alignment cannot be created (an Internal Exception).

Nothing about what the problem could be. References are not nulls, and view is a 3D view. I tried in a PlanView as well.

 

Other suggestions ?

is There any method that I can use, to align elements to a face?

 

Thanks,

 

0 Likes
Message 4 of 12

Revitalizer
Advisor
Advisor

Hi,

 

may it be that this problem is related to yours?

When "picking faces", this comes to my mind:

https://forums.autodesk.com/t5/revit-api-forum/incorrect-face-normal/m-p/7108787

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 5 of 12

Anonymous
Not applicable

Hi,

 

I've verified the faceNormal but both are the same.

 

Thank you for the suggestion.

0 Likes
Message 6 of 12

jeremytammik
Autodesk
Autodesk

Can you achieve what you need manually in the user interface?

 

If not, you won't be able to do it programmatically either.

 

The UI mostly gives more precise feedback.

 



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

0 Likes
Message 7 of 12

matthias.deisboeck
Contributor
Contributor

I have two possible ideas:

1.  If you created the elements you shoud regenerate the document before placing the alignment.

 

2.  Geometrically aligned not only means same FaceNormal also the origin of Face1 must be on Face2.

Perhaps you write a small test programm if you can find this two faces.

In your case you could also project the endpoint of Beam2 to Face1.

 

0 Likes
Message 8 of 12

Anonymous
Not applicable

Yes, I can. With Align command works perfectly.

0 Likes
Message 9 of 12

jlpgy
Advocate
Advocate

Hi:

Try this:

newalignment-to-align-family-instance-reference-plane-with/m-p/5993390 

the documentation says:
"These references must be already geometrically aligned (this function will not force them to become aligned)."

 

FYI:

The following might also be helpful:

https://forums.autodesk.com/t5/revit-api-forum/newalignment-to-constrain-line-to-face-replicate-pick... 

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 10 of 12

architect.bim
Collaborator
Collaborator

Actually I have the same issue. I am trying to align Extrusion face with Reference Plane. Two references are definetly geometrically aligned. But when I try to call NewAlignment method I get the same Exception. Actually I have no idea why this happens. I've tried to regenerate document or adjust the size of the Reference plane. Still not working. =((


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 11 of 12

architect.bim
Collaborator
Collaborator

False alarm. 😆 Actually I took the wrong face. Now works fine.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 12 of 12

architect.bim
Collaborator
Collaborator

In my case regenerating of document really helps as my Extrusion object is created in the same Transaction. Thanks @matthias.deisboeck for the idea!


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes