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: 

Draw Detail Line in View Section Fails to draw line on plane or just returns null

1 REPLY 1
SOLVED
Reply
Message 1 of 2
FrankHolidaytoiling
204 Views, 1 Reply

Draw Detail Line in View Section Fails to draw line on plane or just returns null

I have a ViewSectrion that I want to draw a filled region at the bottom boundary of the viewsection boundary, as a start I tried to create a line diagonally across the min, max corners and only get a null return value. I have also tried using the UV values of the UVboundingbox of the view and would get line is not on plane error. Do I need to perform a transform as I have accessed corner points and placed detail components in elevation views in the past without any error.

 

BoundingBoxXYZ cropBox = viewSection.CropBox;
XYZ point0 = new XYZ(cropBox.Min.X, cropBox.Min.Y, 0.0);
XYZ point1 = new XYZ(cropBox.Max.X, cropBox.Max.Y, 0.0);
Line line = Line.CreateBound(point0, point1);

//Plane plane = Plane.CreateByNormalAndOrigin(viewSection.ViewDirection.Normalize(), viewSection.Origin);

using (Transaction t = new Transaction(doc, "Create Line"))
{
t.Start();
try
{
//SketchPlane sketch = SketchPlane.Create(doc, plane);
DetailCurve detailLine = UiDoc.Document.Create.NewDetailCurve(viewSection, line);

1 REPLY 1
Message 2 of 2

Try without the try catch. It may give you more of an indication.

 

It seems however you are drawing the line in the view coord system and not the model coord system. Your cropbox would report its min/max local to the BoundingBoxXYZ system of cropbox which then has a transform to the global system.

 

People seem to say quite often 'it worked previously' but I'm not sure how that could be true here? If you set the z to 0 then you are effectively placing the line flat on the bottom of the model.

 

I can understand why this can cause confusion however you should think about it this way: When you use Line.CreateBound it doesn't know you are placing that line in a view that has a local system it just knows you are placing a line in the model so assumes global coords are being used (at the time it is created it has nothing to tell it otherwise). However in most cases it would be awkward to define lines in model coords when drawing in a section so you often draw them local to view system and transform them to global (before using them to create things).

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community