Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reference Plane from Reference Point

4 REPLIES 4
Reply
Message 1 of 5
Crashnorun
1839 Views, 4 Replies

Reference Plane from Reference Point

Hi All,

 

I've run into a snag. I've searched high and low through the Revit SDK documentation as well as various forums and I haven't been able to find a solution. In the Revit family environment I am drawing two reference points (RefArrPts) and drawing a reference line (crv) that connects the two points. In the next step I extract the reference points from the reference line (CrvRefPts). In the last step I try to extract the XY plane (plnRef) from the reference points (CrvRefPts). The returned value is of type REFERENCE, the element id of plnRef is the same element id of the CrvStRefPt. The method GetCoordinatePlaneReferenceXY() states it returns a reference to the XY plane of the coordinate system, but it is returning a reference to the point. Would you happen to know what I'm doing wrong? Any guidance would be greatly appreciated.

  

CurveByPoints crv = RvtDoc.FamilyCreate.NewCurveByPoints(RefArrPts);         
crv.IsReferenceLine = true;                                                                              
ReferencePointArray CrvRefPts = crv.GetPoints();                                             
ReferencePoint CrvStRefPt = CrvRefPts.get_Item(0);                                        
plnRef = CrvStRefPt.GetCoordinatePlaneReferenceXY();                                  
 
The line I am drawing is not orthogonal; therefore, I need to extract the plane from the curve end points so that the plane is perpendicular to the line. If I extract the plane from the original two points, I will get planes orthogonal to the world coordinates, which is not useful to me.
 
4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: Crashnorun

You can generate those planes yourself like this:

 

  XYZ p1 = first point
  XYZ q2 = second point
  XYZ v = p2 - p1
  XYZ normal = v.Normalise
  Plane plane1 = Plane.Create( p1, normal )
  Plane plane2 = Plane.Create( p2, normal )

It depends what you want to do with them, of course.

 

If you require a reference to an existing plane element in the model, you could search all of them for one with a matching origin and normal vector.

 

I hope this helps.

 

Cheers,

 

Jeremy



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

Message 3 of 5
Crashnorun
in reply to: jeremytammik

Hi Jeremy,

 

Thanks for the reply. Your solution would work, but my end goal is slightly different. The reason for extracting these planes is to then draw geometry on them (via the SDK) and then allow the user to move the line and have the constrained geometry update. The steps the user would execute are as follows:

1) User will run command that will draw the line and the geometry on the reference planes

2) User can move the line as they desire within the model, all geometry will update. 

Message 4 of 5
FAIR59
in reply to: Crashnorun

the planes you're after, are faces of the solid of the reference line (the solid in crv.get_geometry()). Unfortunately they don't have a reference. If you require a reference to host the geometry, then you'd have to host 2 extra reference points on the reference line and use the references from those.

 

				ReferencePoint rPnt0 = null;
				ReferencePoint rPnt1 = null;
				using (SubTransaction st = new SubTransaction(RvtDoc))
				{
					st.Start();
					PointLocationOnCurve location = new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, 0, PointOnCurveMeasureFrom.Beginning);
            		PointOnEdge pointOnEdge = RvtDoc.Application.Create.NewPointOnEdge( crv.GeometryCurve.Reference, location);
            		rPnt0 = RvtDoc.FamilyCreate.NewReferencePoint(pointOnEdge);
					location = new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, 1, PointOnCurveMeasureFrom.Beginning);
            		pointOnEdge = RvtDoc.Application.Create.NewPointOnEdge( crv.GeometryCurve.Reference, location);
            		rPnt1 = RvtDoc.FamilyCreate.NewReferencePoint(pointOnEdge);
            		st.Commit();
				}
				ReferencePointArray CrvRefPts =  new ReferencePointArray();
				CrvRefPts.Append(rPnt0);
				CrvRefPts.Append(rPnt1);
				
				ReferencePoint CrvStRefPt = CrvRefPts.get_Item(0);
				plnRef = CrvStRefPt.GetCoordinatePlaneReferenceYZ(); 

 

 

Message 5 of 5
Crashnorun
in reply to: FAIR59

Hi Fair59,

 

Thanks for your response. You worded it quite clear. I'm surprised a user cannot extract the end planes from the reference line. I always hesitate having to create more geometry on top of existing geometry to help keep the file size down and also simplify the code, but it seems there is no other way (yet). I will try to add this topic to future wish list for the Revit SDK. Your solution is a good alternative. Thanks for your help!

 

Cheers.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community