Move a family instance of an offset but keeping it parallel to a line

Move a family instance of an offset but keeping it parallel to a line

Anonymous
Not applicable
2,321 Views
12 Replies
Message 1 of 13

Move a family instance of an offset but keeping it parallel to a line

Anonymous
Not applicable

Hi guys, I'm a C# developer with little knowledge of Revit APIs. What I'm trying to do is to create a room starting from a series of "ModelLine" drawed by the user. Each wall is composed with various panels (which are instances of a family), each panel needs to be oriented to be parallel in respect of the drawed ModelLine, and everything is fine but I have a problem (the last one I hope).

 

The family instance origin is set to the top-left corner of the panel also the family was drawn so that the panel is horizontal if I open the RFA, when I rotate the panel is placed in the right position but outside the shape, as an example look at the picture below, the bottom and right panels are ok, the upper and left panels aren't because I rotate every panel to make them parallel to the drawn line (the blue polygon), if needed.

001.png

 

What I want to accomplish is shown below, where each panel is placed inside the shape. I think that I need to calculate a vector and move the rfa instance by the thickness of the panel, but:

 

How I can calculate the vector? and how I can know if I need to move the panel "inward" or "outward"? Sorry but my cad/math skills aren't so good so this question might be quite stupid to the eye of a professional Revit developer. Please also note that the shape can have different angles and shapes than an simple rectangle.

 

Thanks in advance for your help, 

Umberto

002.png

0 Likes
Accepted solutions (1)
2,322 Views
12 Replies
Replies (12)
Message 2 of 13

jeremytammik
Autodesk
Autodesk

Dear Umberto,

 

You question is impossible to answer as it stands.

 

How is the add-in to know on which side of the model line to place the family instance?

 

If you can guarantee consistency, e.g., "always place the family instance on the left side of the line when looking from start point to end point", everything would be easy.

 

If the model lines were walls, they would have an inside and an outside face, and everything would be easy.

 

As it is, without further constraints or information, no answer can be made.

 

You probably have assumptions about your model in your head that you have not told us about.

 

Cheers,

 

Jeremy

 



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

0 Likes
Message 3 of 13

Anonymous
Not applicable

Hi Jeremy, 

Glad to meet you. You're right I try to add few information about the issue.

 

I know exactly which is the first segment and then the others drawn by the user (the user must draw the shape in chain mode, so every segment is ordered from the start to the end, clockwise or anticlockwise), also those segments aren't walls (but yours is a good point to look at) I draw a series of ModelLines and then I put the family instances at each step (the panel length which is a parameter is the step size) that from a code point of view it is a point placed in the line.

 

About where to place the instance I can't say (and this is my problem) on which side of the line I want the panels, it depends from the angle and the position of the line, in words I need that each panel (and its thickness) falls inside the polygon, in the example below I want just three series of panels inside the polygon area the bottom and rightmost series are ok.

 

003.png

 

Thanks in advance for your help and time, and if you need more information just ask.

 

Umberto

 

P.S. Below you have the rfa file as I received it.

 

004.png

 

 

 

0 Likes
Message 4 of 13

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Umberto,

 

Nice to meet you too.

 

The way you describe it, you do know which side of the line you wish to place the instance on.

 

You say you "draw the shape in chain mode, so every segment is ordered from the start to the end, clockwise or anticlockwise".

 

You can determine whether it is clockwise or anticlockwise, and you can even reverse the former to guarantee you always have the latter.

 

Then, you will always have the inside of the polygon on the left hand side of each line segment, when looking along the line from start to end.

 

That is the point I already made in my first answer.

 

I hope this clarifies.

 

Cheers,

 

Jeremy



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

Message 5 of 13

Revitalizer
Advisor
Advisor

Hi,

 

the problem seems related to the point-in-polygon-problem:

http://forums.autodesk.com/t5/revit-api-forum/how-to-determine-if-a-point-xyz-is-inside-a-curveloop-...

 

If you define points using the wall's face's normal (or points left and right of the LocationCurve, or wall's orientation and its negation...), you could determine which side of a wall is the inner one, independed of the creation order, CW or CCW.

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 6 of 13

FAIR59
Advisor
Advisor

You are placing some families using the wrong direction (red arrows). When you use the direction of the green arrows, all your families will be at the same side of the lines.

 

 

0 Likes
Message 7 of 13

FAIR59
Advisor
Advisor

You are placing some families using the wrong direction (red arrows). When you use the direction of the green arrows, all your families will be at the same side of the lines.

 

 

If you have an open loop then you have to ask the user for the interior / exterior side.

DrawDirection.JPG

0 Likes
Message 8 of 13

Anonymous
Not applicable

Hello everyone and thanks for your help!

 

Today I try to use your suggestions (looking for clockwise/anticlockwise segments order) I think that I will be able to solve the issue.

 

I'll keep you updated on the issue!

 

Umberto

0 Likes
Message 9 of 13

Anonymous
Not applicable

Hi Jeremy,

 

just a question, having a list of ModelCurves, how I can tell if they were drawn in clockwise or anticlockwise order, there is something in the Revit API which could help me? Also when I determine the direction then I have only the insertion point of the panel which falls exactly on the line, so how I can determine if the line is left hand (so I know that I need to translate the panel inward by its thickness) having just the line start/end point and the insertion point exactly on the line?

 

Sorry for the stupid questions but my math/geometrical skills are terrible!

 

Umberto

0 Likes
Message 10 of 13

jeremytammik
Autodesk
Autodesk

If you know a point inside the polygon, you can use its winding number to determine which way around it goes:

 

https://en.wikipedia.org/wiki/Winding_number

 

Cheers,

 

Jeremy



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

0 Likes
Message 11 of 13

jeremytammik
Autodesk
Autodesk

Just perform an Internet search for "polygon clockwise".

 

The first hit that appears for me is this:

 

http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clock...

 

Do you not have a search engine yourself?

 

Cheers,

 

Jeremy



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

0 Likes
Message 12 of 13

Anonymous
Not applicable

Thanks Jeremy,

 

Now I can check if the segments are clockwise or not 🙂 I was thinking that I need some obscure calculation or API call... then god save Google.

 

I move one the last step, but this time I do some research for mysef 😉

 

In the meantime thanks.

 

I'll keep everyone here updated on the progress, that post could be useful also for other users.

 

Umberto

0 Likes
Message 13 of 13

Anonymous
Not applicable

Hi Jeremy thanks to your advice I was able to move forward (only now I had other task to do before I can continue to this new command for my company). I have only one thing left, but first I search on the internet for a solution, before asking there.

 

Again thanks,

Umberto

0 Likes