Offset Multiple

Offset Multiple

revitaddins
Contributor Contributor
1,744 Views
7 Replies
Message 1 of 8

Offset Multiple

revitaddins
Contributor
Contributor

Hi guys,

 

what's the best way to offset a line multiple times? I'm struggling to do it ;/

 

for(int i = 0; i < (numberOfOffset); i++ )
                    {
                       
                        XYZ normal = XYZ.BasisZ;
                        Curve newLine = LongLine.CreateOffset(2000, normal);
                        doc.Create.NewDetailCurve(doc.ActiveView, newLine);

                    }

 

basically i need an array of lines

 

Thanks in advance.

0 Likes
Accepted solutions (1)
1,745 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni

That looks perfectly fine to me.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 8

RPTHOMAS108
Mentor
Mentor

You are offsetting by 610m since internal units are ft.

Message 4 of 8

jeremy_tammik
Alumni
Alumni

Wow, very perceptive reading and guesswork!

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 8

revitaddins
Contributor
Contributor

Thank you @RPTHOMAS108 , 

  double offset = UnitUtils.ConvertToInternalUnits(2000, DisplayUnitType.DUT_MILLIMETERS);

I converted it, but the problem is the lines stays in the same position

 

revitaddins_0-1616516380716.png

 

0 Likes
Message 6 of 8

RPTHOMAS108
Mentor
Mentor

I can't see from that what is wrong where is LongLine? Was you offsetting 2m from the adjacent wall (this looks about 2m judging from door)?

 

If you want cumulative offset for each iteration of your loop then you need to multiply distance by iteration or add it to running total each time (not just keep offsetting same distance from same line).

 

Thanks @jeremy_tammik as internal units are not metric I don't expect them to be rounded so nicely.

0 Likes
Message 7 of 8

revitaddins
Contributor
Contributor

Yes the offset will start from long line, and yes I guess that's what I need, cumulative distance, sorry for ignorance but that's where I'm failing, would you mind giving an example? Thanks 

0 Likes
Message 8 of 8

RPTHOMAS108
Mentor
Mentor
Accepted solution

It is also worth mentioning that your offset direction is going to be based on the direction of the line being offset. So for some instances you may have to either use (0,0,-1) rather than BasisZ or multiply offset value by -1 to get the direction of offset you want. 

 

Dim Offset as Double = 304.8
For I = 1 to NumberOfOffsets
  Dim Total = I * Offset
  Dim NxtLine = LongLine.CreateOffset(Total, XYZ.BasisZ)
...
Next

 

or

 

Dim Offset as Double = 304.8
Dim Total as double = 0
For I = 0 to NumberOfOffsets - 1
  Total += Offset
  Dim NxtLine = LongLine.CreateOffset(Total, XYZ.BasisZ)
...
Next

 

 

0 Likes