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: 

Section view

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
ahmed.errazak
923 Views, 10 Replies

Section view

Hello, there is someone who could tell me why it does not work ONLY in SECTIONVIEW ?
Here is an example of my program (sorry I am a beginner)
and still sorry for my English (google translate (° _ °))

 

 

{
Transaction Trans = new Transaction(Doc);
Trans.Start("Draw Xref");
Autodesk.Revit.ApplicationServices.Application application = Doc.Application;
XYZ pt1 = Sel.PickPoint("Get First Point");
XYZ pt2 = Sel.PickPoint("Get Second Point");
XYZ VectAngle = pt2 - pt1;
double RadAngle = VectAngle.AngleTo(XYZ.BasisX);
double X3, Y3;
double X0, Y0;
int linelength = 150000;
X0 = ((linelength * Math.Cos(RadAngle + Math.PI)) + pt1.X);
Y0 = ((linelength * Math.Sin(RadAngle + Math.PI)) + pt1.Y);
X3 = ((linelength * Math.Cos(RadAngle)) + pt2.X);
Y3 = ((linelength * Math.Sin(RadAngle)) + pt2.Y);
XYZ Pt0 = new XYZ(X0, Y0, pt1.Z);
XYZ Pt3 = new XYZ(X3, Y3, pt2.Z);
Line geomLine = Line.CreateBound(Pt0, Pt3);
DetailLine line1 = Doc.Create.NewDetailCurve(MView, geomLine) as DetailLine;
Trans.Commit();
}

10 REPLIES 10
Message 2 of 11

Dear Ahmed,

 

Thank you for your query.

 

If you are new to the Revit API, and maybe to programming in general, I first of all welcome you to this topic and forum!

 

Before diving any deeper into programming more complex tasks, I would suggest that you work through the Revit API beginners material, especially the video tutorial:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will explain all the important basics, deepen your understanding, and clarify many questions up front.

 

Also, please be aware of the importance of understanding Revit and the BIM from an end user point of view before trying to achieve anything programmatically:

 

https://thebuildingcoder.typepad.com/blog/2018/06/extensible-storage-and-renaming-a-family-in-a-proj...

 

Otherwise, you might quickly find yourself in a situation where your add-in is trying to work against the BIM system instead of making proper use of its powerful built-in functionality.

 

Once you have a good grasp of the basics of both the Revit API and the end user view of the BIM task you are addressing, it is time research how to solve your task programmatically:

 

https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...

 

If you run into an issue after you know what you want to achieve, have ensured that it makes sense in the BIM workflow, have ensured that it can be solved programmatically at all and have done research on how to address it, the time has probably come to ask a question about the specific problems you encounter.

 

When you ask a question, it is important to do so in an intelligent and intelligible manner. For instance, please ask your question in full.

 

I have no idea what the code snippet that you share is supposed to achieve. You need to tell me.

 

Please explain your goal, the context, the workflow, the expected behaviour, the actual real behaviour, and why that is a problem for you. Do all that, and at the same time keep it really brief and to the point.

 

I cannot guess what you are trying to achieve.

 

Here are some hints on how to ask a question in general:

 

https://www.wikihow.com/Ask-a-Question-Intelligently

https://www.lifehack.org/articles/communication/how-amazingly-good-asking-questions.html

 

More specifically, here are important recommendations on asking a question about solving a programming task:

 

https://stackoverflow.com/help/how-to-ask

 

This last one is a really important post, so please read it in full!

 

Here are a few thousand other good suggestions on asking questions well:

 

https://duckduckgo.com/?q=how+to+ask+a+question

 

I hope this helps.

 

Please understand that I do not want to criticise your question. I just want to help you get an effective answer.

 

I wish you much success getting started with the Revit API and look forward to further questions from you in the near future.

 

Best regards,

 

Jeremy

 



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

Message 3 of 11

I do not know what to answer, your answer let me perplexed


If I had to know everything you put in touch, I would need months of study.

And I would not have had the need to register on the forum and ask for help.

 

I did not have any programmer training or BIM anything, I learned about books or the net  I try to take some hours on my family time and the evening on my pc I try at my level to make small program for more automation.

But seeing my lack of knowledge sometimes I block on basic fault And for people like me a forum like this is a lights in the dark, And I try to come to this light and hope to have a piece of answer or a direction to take in the resolution of my little program.

And so far there have been people nice enough to answer me and tell me the right way to go (I thank them).

 

I would never think that "Jeremy Tammik" will take the time to answer a beginner like me. Or you had a bad day and you let off steam on me who knows?

I say that because I have already read on the site questions even more "abstract" than mine and no one has answered them in this way (well let's try to stay positive).

 

But if I understood the operation of the site, there is no obligation to answer one or the other It is only by altruism, no?

And again sorry for my english (I speak french and dutch ) and of course Arabic too

Message 4 of 11

Dear Ahmed,

 

Thank you for your update and very sorry I gave you the impression of letting off steam.

 

That is definitely not my intention.

 

And your English is absolutely fine, no need to worry about that at all. You can definitely list English as well among the languages you speak!

 

I really seriously believe that every question is good and deserves an answer.

 

It is also a fact that a well formulated question is much easier to answer than a less well formulated one.

 

In this specific case, I repeat what I said above:

 

I do not know what the sample code snippet you included is intended to achieve.

 

Please explain what your intention is.

 

Thank you!

 

And please do read and take heed of the StackOverflow instructions on how to ask a good question.

 

This is not targeted at you, but at all forum participants, just as the StackOverflow instructions are aimed at all StackOverflow participants.

 

I am sorry to say that your question still violates several of them:

 

Thank you!

 

I look forward to helping you resolve your issue.

 

I just first need to hear from you what the issue is at all  🙂

 

The two hints so far, 'section view' and 'it does not work' are just not descriptive and precise enough.

 

Best regards,

 

Jeremy

 



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

Message 5 of 11
Revitalizer
in reply to: ahmed.errazak

Hi,

 

I don't know what you want to do, but you should check the values returned by your Sel.PickPoint statements.

The points may not be the ones you expect - although you have a 2D view, the points may reside far beyond the view's SketchPlane, just anywhere inside the 3D model, depending on the point snap options.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 11
ahmed.errazak
in reply to: Revitalizer

Hello

If I understand correctly, I have to transform my 3D coordinates returned from my Self.PickPoint to 2D coordinates

Message 7 of 11
Revitalizer
in reply to: ahmed.errazak

Hi,

 

yes, exactly.

You say that it didn't work in section views only, but I think it wouldn't work in elevation views, too.

What do you want to perform?

Draw a DetailLine in a given view?

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 11
ahmed.errazak
in reply to: Revitalizer

Hello

Yes, I would like to draw a Xline (detail line) in the Sectionviews so that I can align the elements on it

Message 9 of 11
ahmed.errazak
in reply to: Revitalizer

Hello
I try to convert the 3D coordinates to 2D, but that bug on "Sel.Pickpoint"
_ Or "Sel.Pickpoint" can not be used in elevations and section ???
_ Or so I made a mistake in the function!

 

 Dim Trans As Transaction = New Transaction(Doc)
        Trans.Start("Draw XLine")
           Dim SnapTypes As ObjectSnapTypes = ObjectSnapTypes.None
           Dim pt1 As XYZ = Sel.PickPoint(SnapTypes, "Get First Point")
           Dim pt2 As XYZ = Sel.PickPoint(SnapTypes, "Get Second Point")

       'REM Convert to 2D
           Dim StartPoint As XYZ = New XYZ(pt1.X, pt1.Y, 0)
           Dim EndPoint As XYZ = New XYZ(pt2.X, pt2.Y, 0)
 
           Dim DrawLine As Line = Line.CreateBound(StartPoint, EndPoint)
           Dim Xline As DetailLine = Doc.Create.NewDetailCurve(MView, DrawLine)
         
 Trans.Commit()

Message 10 of 11
Revitalizer
in reply to: ahmed.errazak

Hi,

 

here is all you need for geting the points, projected onto the Plane of the View's SketchPlane:

https://thebuildingcoder.typepad.com/blog/2014/09/planes-projections-and-picking-points.html

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 11
ahmed.errazak
in reply to: Revitalizer

thank you

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