Outline class

Outline class

christian.stan
Collaborator Collaborator
335 Views
2 Replies
Message 1 of 3

Outline class

christian.stan
Collaborator
Collaborator

Hello,
Apart from the fact that I don't know how to code very well, you'll realize that by reading the code.

Why doesn't the Outline class return the correct line?
The four points of the face are normally on the same line (two quadrants don't work well).

If anyone has an explanation, I'd appreciate it.

christianstan_0-1743270948939.png

public List<XYZ> findp(Face f)
		{
			List<XYZ> lpts=new List<XYZ>();
			var clt=f.GetEdgesAsCurveLoops();
			foreach (CurveLoop cl in clt)
			{
				foreach (Curve c in cl)
				{
					lpts.Add(c.GetEndPoint(0));
				}
			}
			return lpts;
		}
		
		public void cline()
		{
			Document doc=this.Document;
			UIDocument uidoc=Application.ActiveUIDocument;
			//choix du mur
			Selection choix = uidoc.Selection;
			Reference choixselection = choix.PickObject(ObjectType.Element);
			Wall w=doc.GetElement(choixselection) as Wall;
			IList<Reference> refext=HostObjectUtils.GetSideFaces(w,ShellLayerType.Exterior);
			Face fext=w.GetGeometryObjectFromReference(refext[0]) as Face;
			XYZ pdeb=findp(fext)[0];
			XYZ pfin=findp(fext)[3];
			Outline ol=new Outline(pdeb,pfin);
			ol.AddPoint(findp(fext)[1]);
			ol.AddPoint(findp(fext)[2]);
			Line l=Line.CreateBound(ol.MinimumPoint,new XYZ(ol.MaximumPoint.X,ol.MaximumPoint.Y,ol.MinimumPoint.Z));
			Transaction t = new Transaction(doc,"create a grid align on face wall");
			t.Start();
			Grid lineGrid = Grid.Create(doc, l);
			t.Commit();	
		}

 

Christian.stan

0 Likes
Accepted solutions (1)
336 Views
2 Replies
Replies (2)
Message 2 of 3

longt61
Advocate
Advocate
Accepted solution

Firstly, let us understand the Outline a bit better.
The Outline, as well as BoundingBoxXYZ, represents an Axis Align Bounding Box (AABB), which mean the 3 axes always conforms to the default X, Y, Z axes.  Without properly transformation, the newly created Outline is always a box where X axis points to the right, Y axis points away from you, Z axis points upward. Besides, the Outline will be a box that completely contains the element and it will be as small as possible.

 

Secondly, let us answer your question.

Since Outline is an AABB, the Minimum point is the bottom left point, the Maximum point is top right point. Thus, the grid you created will always point from left to right, down to top. In other words, it will always be in the first quadrant.

 

Finally, how to solve your problem.

Depending on the type of element you are working on, you can utilize its geometry properties to determine the start point and end point correctly. This can be done in various way, such as getting the Location Curve then get start-end points, getting the FamilyInstance hand orientation vector and placement point, etc...

My fuzzy guess is that you are working with beam or wall, so my first solution should be sufficient.

Message 3 of 3

christian.stan
Collaborator
Collaborator

Hello, and thank you for the explanation. I understand.

Sincerely,
Christian.stan

0 Likes