Rotate problem

Rotate problem

Anonymous
Not applicable
487 Views
1 Reply
Message 1 of 2

Rotate problem

Anonymous
Not applicable

Hi

I read an article ( Text File Driven Automatic Placement of Family Instances ) from Jeremy Tammik's blog

 

For Know , I know the way to create instances by a text file contains XYZ coordinates , then I try to rotate the instances at the same time . 

 

But it seems to be not successful . Here's the picture of my consequence.

 錯誤圖.jpg

 

 

As you see , it create several times by different angles...

 

But what I really want is like the picture below that every instance has different angle. 

 

正確圖.jpg

 

And here's my key code(which came out the unsuccessful picture).

 

 

foreach (XYZ p in Points)
{
  foreach( double d in Degree)
  {
    familyInstance = creation_doc.NewFamilyInstance(p, Type, st);                        
    XYZ p2 = new XYZ(p.X, p.Y, p.Z + 10);
    Line axis = Line.CreateBound(p, p2);                
    ElementTransformUtils.RotateElement(doc, familyInstance.Id, axis, d);
  }                                                          
}

 

I don't know how to correct it .

 

Please do help me , thank you .

 

 

 

 

 

0 Likes
Accepted solutions (1)
488 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

As I see it you are going through all the points

and add a family on each rotation point:

 

foreach (XYZ p in Points)
{  foreach( double d in Degree)
  {
Insert + Rotate
}
}

This means you will get way to many families, actually the corect inserted and rotated family is simply covered by all the wrong ones..

 

so you need to only insert ONE family per coordinate, and THEN insert and rotate it.

 

if your Points and Rotations are in a List<> then you can use its index to find the respected double (depending on your text file)

 

in semi-psudocode:

 

i == 0;
if(Points.Count == Degrees.Count)
{
for(int i = 0, i < Points.Count, i++) {
XYZ p = Points[i];
double d = Degrees[i];

insert family on p and rotate with d bla bla

}
}

... you know what to do...

 

or if you work with a number of text files or need more flexibility you need to create your own list of a class where you store each XYZ and double and then go through them..

 

Hope this helps...