Element Reversed

Element Reversed

harilalmn
Advocate Advocate
2,274 Views
9 Replies
Message 1 of 10

Element Reversed

harilalmn
Advocate
Advocate

Hi All,

I am creating a wall and rotating it using revit api calls in Python. It has created many walls successfully, but for a few walls, it raised a warning saying Element is reversed and I have no choice but to delete it. Before committing the transaction, is there a way to check if the element is reversed? Or what is causing this error....!?

 

I have a 'Wall_Data" class, which has various properties of the wall and there is a method to create the wall instance.

 

I create the wall like this;
wall = Wall.Create(doc, self.curve, self.wall_type.Id, self.base_level.Id, self.height, self.wall_offset, False, False)

 

Any idea how to fix this?

0 Likes
Accepted solutions (1)
2,275 Views
9 Replies
Replies (9)
Message 2 of 10

RPTHOMAS108
Mentor
Mentor

That is an editing failure i.e. not due to wall creation but editing:

BuiltInFailures.EditingFailures.ElementReversed

 

So is it actually occurring during your rotation attempt? Swap ends of wall prior to creation with Curve.CreateReversed instead of Rotating wall after creation.

 

I don't really get your workflow in terms of why you need to rotate after creating the wall. You must know which way around you are creating it in relation to an orientation you care about, so what stops you orientating it correctly to start with?

0 Likes
Message 3 of 10

harilalmn
Advocate
Advocate

Thanks a lot for that advice.. I will try.

0 Likes
Message 4 of 10

harilalmn
Advocate
Advocate

Ok, it is caused by the rotate command. Now, this being happenning only for some caurtain walls, I will reverse the curve "if the element is reversed" and re-create it. But could you please tell me how to check if the element is reversed before committing the transaction of rotate command? Is that ElementReversed property of a boolean type, so that I can write soimething like; if wallObject.ElementReversed: curve.CreateReversed() 

0 Likes
Message 5 of 10

RPTHOMAS108
Mentor
Mentor

I believe there is no such thing as a reversed wall it is telling you the wall cannot be rotated or it will become reversed (cannot be rotated into that position). By what angle are you rotating it after creation and why?

 

This is something that would happen in the UI if you tried to rotate it and probably relates to degree of rotation and current position. What method are you using to rotate?

0 Likes
Message 6 of 10

harilalmn
Advocate
Advocate

Actually the element is a curtain wall. This curtain wall is used where ever a door has to be placed. Please note that the Revit standard door family is not used for doors and windows, instead, for some reason, curtain wall is used, which is set to embed into the generic wall which is supposed to be the host for these doors and windows. The data is coming from an XML file. The XML element which describes the door has child nodes for;

 

1. Location - xyz values separated by whitespace

 

2. Rotation - angles for x, y and z axis separated by whitespace, like;

"0 0 90", which means door is rotated by 90 degrees on z axis

 

3. Mirrored - like rotation but 1 or 0 for x, y and z indicating boolean values

 

This is how I rotate it.

 

ElementTransformUtils.RotateElement(doc, self.door_id, self.z_axis,self.rotation_z

 

 

A typical door definition in XML is as follows;

 

<object>

<asset id="206"/>

<type door</type>

<points>11.573 3.972 0</points>

<size>0.9 0.1 2.2</size>

<rotation>0 0 90</rotation>

<mirrored>0 0 1</mirrored>

</object>

0 Likes
Message 7 of 10

RPTHOMAS108
Mentor
Mentor
Accepted solution

I don't fully understand your description regarding door/window elements. As far as I'm aware there are curtain walls that can host curtain panel doors, system curtain panels etc. Then there are walls (non-curtain walls) that can't host curtain anything. Do you have an small sample file with a brief IExternalCommand that demonstrates the issue i.e. placing the wall, doors etc then rotating the thing that is causing the issue.

 

As an alternative to ElementTransformUtils you could try rotating via  Location.Rotate or changing the LocationCurve if applicable. It sounds however that the built-in failure is due to one elements relation to another perhaps.

0 Likes
Message 8 of 10

mhannonQ65N2
Collaborator
Collaborator

Try rotating the element's position and/or orientation before you place it.

For example, with a door hosted on a wall, use this method:

Autodesk.Revit.Creation.Document.NewFamilyInstance(
	XYZ location,
	FamilySymbol symbol,
	XYZ referenceDirection,
	Element host,
	StructuralType structuralType
)

Where referenceDirection is the direction you want the door to have. To calculate the referenceDirection, create a transform for the specified rotations and apply it to the default direction vector of the family (for a door, I think this would be <0,1,0>).

 

For a wall, you would have to rotate the curve before you pass it into the method used to create the wall.

If you cannot figure out how to rotate the curve (AFAIK, Revit's API does not provide a convenient method for rotating curves), you could create a ModelCurve, rotate it, then get it's LocationCurve, making sure to commit the transaction before and after rotating it. You probably also want to delete the ModelCurve afterwards.

0 Likes
Message 9 of 10

harilalmn
Advocate
Advocate

@RPTHOMAS108 

Thanks for the advice. As you have advised, I have rotated the curve instead of rotating the wall and it worked. But this too was a bit challenging for I could not figure out how to rotate that "Line in space". But I did it by creating a function like this;

 

def rotated_coords(point,center,angle):
    x, y = point
    p, q = center
    a = angle
    return XYZ(
        (x-p) * math.cos(a) - (y-q) * math.sin(a) + p, 
        (x-p) * math.sin(a) + (y-q) * math.cos(a) + q, 
        0
    )

  I don't know if this is the efficient way of dealing with the problem, but this worked. Thanks again...

0 Likes
Message 10 of 10

harilalmn
Advocate
Advocate

@mhannonQ65N2 

Thanks for the reply. I had done the same, but in a different way. I did not want to go for that extra step of creating a model curve and then delete it after creating the wall. So I managed it with another function to get the rotated end points of the 'Line in space'. Kindly check my reply for @RPTHOMAS108 . I have shared the function I used.