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: 

How to draw a line with offset through API?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
sankar_g
3673 Views, 4 Replies

How to draw a line with offset through API?

Hi,

 

                   In Revit as a user we can create line with offset value. I want to achieve the same through API.

 

                   Is it possible? then how can we achieve that?

 

Thanks,

4 REPLIES 4
Message 2 of 5
thiago.loddi
in reply to: sankar_g

You can use the command Line.CreateBound(startpoint, endpoint)

 

startpoint and endpoint are XYZ objects where you put the coordinates of a vector, so in the Z coordinates you choose your offset.

It will be somthing like:

 

Dim startpoint As Autodesk.Revit.DB.XYZ

Dim endpoint As Autodesk.Revit.DB.XYZ

Dim line As Autodesk.Revit.DB.Line

 

 

startpoint = New Autodesk.Revit.DB.XYZ(0, 0, 10)

endpoint = New Autodesk.Revit.DB.XYZ(2, 2, 10)

 

line = Line.CreateBound(startpoint, endpoint)

 

This will create a line from coordinates (0, 0) to (2, 2) with base offset of 10.

Hope it helped

Bye

Message 3 of 5

Hi,

 

You may want to, for a given line, get the location curve, then clone this curve, call a move on it passing the offset you need, then use this cloned-moved curve to create a new one...

 

Does that help?

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 4 of 5
Joe.Ye
in reply to: sankar_g

Hi Sangsen,

ElementTransformUtils.CopyElement(Document, ElementId, XYZ translation) can be used to create a line with offset value. This method's third argument is a vector, so you need to calculate the offset direction and the offset distance to form a vector.


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 5 of 5
michael_coffey
in reply to: sankar_g

Joe,
I can create an offset with the CopyElement just fine, the problem I'm having is figuring out which way the vector should go when drawing a wall horizontally on the screen, versus vertically or at an angle. I have a feeling it might be something in the Transform class, but i don't understand that very well. Essentially when creating a wall it defaults to the centerline. I would like it to move 1/2 the width to the Finish face. Any help you can provide is greatly appreciated. Thanks!

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