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: 

ElevationMarker does not Rotate 180 deg

10 REPLIES 10
Reply
Message 1 of 11
grahamcook
1197 Views, 10 Replies

ElevationMarker does not Rotate 180 deg

Hi

I'm working on a room elevation add-in.  Discovered that rotating elevation markers by 180 deg results in an extra 180 deg being added by the API.  In fact, rotating the marker within the range greater than 160 and less than 200 deg will result in the angle being automatically adjusted by 180 deg.  My workaround has been to catch angles in this range, halve it, and perform two rotations.  All other angles rotate fine as demonstrated in the image.

 

Line lineAsAxis = Line.CreateBound(rb.ElevationPoint, new XYZ(rb.ElevationPoint.X, rb.ElevationPoint.Y, rb.ElevationPoint.Z + 1));
 if (angle > 160 && angle < 200)
 {
     angle = angle / 2;
     ElementTransformUtils.RotateElement(doc, elevMarker.Id, lineAsAxis, angle * App.TO_RADIANS);
}
ElementTransformUtils.RotateElement(doc, elevMarker.Id, lineAsAxis, angle * App.TO_RADIANS);

 

Marker1.jpg

Of course I'm not 100% sure of the exact tipping points but 160-200 are the rough limits.  More detailed image attached.

 

Just thought I would mention this limitation.  Was also raised in another post about a year ago with no reply:

https://forums.autodesk.com/t5/revit-api-forum/rotate-elevation-mark-180-issues/td-p/7234149

 

This was tested in 2018.

Thanks.

10 REPLIES 10
Message 2 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

 

Thank you for your interesting report and sorry to hear that it was ignored last time around.

 

Glad to hear you have an effective workaround, at least.

 

I escalated it to an ADN case now to ensure it is not missed: 14258638 [ElevationMarker does not Rotate 180 deg].

 

I also reported it to the development team:

 

I logged the issue REVIT-132231 [RotateElement used on elevation marker adds 180 degrees -- 14258638] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

 



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

Message 3 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

 

Thank you for your patience.

 

The development team analysed your issue REVIT-132231 [RotateElement used on elevation marker adds 180 degrees -- 14258638] and say:

 

I am having trouble reproducing this. I made an interior elevation marker and tried to rotate it using ElementTransformUtils.RotateElement and using the UI. I did not encounter any surprises. I also stepped through the code a little bit and while there were some deprecated functions on the way, the code seemed to be quite general. My initial assessment is that if rotating this particular type of elevation marker does not work, then there should be other things that fail to rotate correctly, as well.

 

I think that the problem might have something to do with how the elevation marker is created. It looks like there are multiple views that can be attached to it. Do I need to create additional views? Similarly, I can see in the screenshot that the room itself is rotated. Since I am not familiar with the behaviour involved here, I need more detailed steps to get into the state that exhibits the extraneous rotation.

 

Best regards,

 

Jeremy

 



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

Message 4 of 11
grahamcook
in reply to: jeremytammik

Thanks.  I will move the code to a standalone macro self contained in one file.  Before I do that here's a little more code showing the key steps:

 

ViewFamilyType vft = (from elem in new FilteredElementCollector(doc)
.OfClass(typeof(ViewFamilyType)) let type = elem as ViewFamilyType where type.ViewFamily == ViewFamily.Elevation select type).FirstOrDefault(); // rb.ElevationPoint is a calculated point mid way along the given // boundary moved perpendicular into the room 900mm. ElevationMarker elevMarker = ElevationMarker.CreateElevationMarker(doc,
vft.Id, rb.ElevationPoint, Settings.SelectedElevationScale.scale); // viewPlan.Id is the level Id the room is located on #region Place elevation at index 0 and rotate to face the wall ViewSection sv = elevMarker.CreateElevation(doc, viewPlan.Id, 0); ElevationViews.Add(sv.Id); sv.ViewName = viewName; sv.Name = viewName; double angle = Math.Round(rb.Angle_Deg, 6); Line lineAsAxis = Line.CreateBound(rb.ElevationPoint,
new XYZ(rb.ElevationPoint.X, rb.ElevationPoint.Y, rb.ElevationPoint.Z + 1)); if (angle > 0) { double rot_angle = angle;
// This includes the correctional code to catch those within the 160-200 range
// basically we divide the angle by 2 and rotate twice. if (rot_angle > 160 && rot_angle < 200) { rot_angle = rot_angle / 2; ElementTransformUtils.RotateElement(doc,
elevMarker.Id, lineAsAxis, rot_angle * App.TO_RADIANS); } ElementTransformUtils.RotateElement(doc,
elevMarker.Id, lineAsAxis, rot_angle * App.TO_RADIANS); }
#endregion
Message 5 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

Thank you for your update.

Looking forward to the standalone macro self contained in one file.

In the meantime, the development team closed your issue REVIT-132231 [RotateElement used on elevation marker adds 180 degrees -- 14258638] and say: Please reopen the issue when you provide the information.

Best regards,

Jeremy

 



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

Message 6 of 11
graham
in reply to: jeremytammik

Dear Jeremy

Sorry about the delay in getting this standalone sample together.  Finally got round to doing it.  The attached model (2018) has the minimal code required to reproduce the issue.  Open the model and run macro ElevationMarker to re-produce the elevation marker rotation issue.  Run macro ElevationMarkerWithFix to see the results with the temporary fix applied.  Image of respective results, the circled marker is the one that is rotated by 180 deg which then gets flipped back:Capture.JPG

Message 7 of 11
grahamcook
in reply to: graham

Sorry, the above post was posted in error using my PremierBIM ADN account "graham@premierbim.com" and not grahamcook.  Can this be corrected to come from grahamcook?

Message 8 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

 

Thank you for your update and reproducible case.

 

I cannot make any changes to your post, I'm afraid; I don't see what significant difference that will make anyway?

 

I reopened the development issue REVIT-132231 [RotateElement used on elevation marker adds 180 degrees -- 14258638] for you and added your updated description and new sample material to it.

 

Best regards,

 

Jeremy

 



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

Message 9 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

 

The development team analysed the issue REVIT-132231 [RotateElement used on elevation marker adds 180 degrees -- 14258638] that I raised for you and determined that a code fix is required for a future version of Revit.

 

The new code fix issue number is REVIT-134773 [RotateElement used on elevation marker adds 180 degrees -- 14258638].

 

Please make a note of that.

 

Here are some notes from their investigation:

 

1) The macro project that demonstrates the problem can be shortened. Go to ProcessElevations and assign the rotation angles directly in the foreach loop. For the octagon the rotation angles should be 45, 90, 135, ..., 315, 0. The first boundary segment is pointing in the direction (1, -1) (or -45 degrees) and the corresponding rotation angle should be 45 degrees. One rotation angle that causes the problem is 180.

 

2) Put a breakpoint in ElementTransformUtils::rotateElement_ . From there it is possible to see the transformations being applied. One key point is in MoveHelper.cpp, performRotatePicks, after the call to rotateElements. This is where transformations are done and regeneration is about to be triggered.

 

3) Regeneration visits a lot of code, so I am not sure about the optimal way for discovering the bug. One way to get started is to put a breakpoint in SectionGraphics::orientBoundedSpace() (see the comment above the function). That particular function seems to be harmless, however. Another possible place is SectionGraphics::updateViewerData(). The next step is to note the class hierarchy of InteriorElevArrow. One of the ancestors is Viewer, which contains a bounded space that is supposed to be synchronized with the orientation of the elevation view and marker. In particular, the forward vector of the bounded space should be the view direction of the marker. The final step is to use a data breakpoint on the forward vector. It will flip from (1, 0, 0) (which is correct for a marker with the default orientation to 180 degrees and that was rotated by 180 degrees) to (-1, 0, 0). This will happen in Viewer::setBoundedSpace indirectly called from SectionGraphics::updateViewerData. Note that the bounded space in Viewer to set the data breakpoint on is the Temp one.

 

Thank you for your patience while this gets resolved for release in a future version of Revit.

 

Best regards,

 

Jeremy

 



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

Message 10 of 11
grahamcook
in reply to: jeremytammik

Thanks for update.  Until the bug is fixed, I have found the best workaround is to rotate the elevation marker in chunks of 30 degrees until the required angle has been met.  My original post suggested this problem was restricted to angles between 160-200 degrees but I've found examples where the problem was evident on angles as low as 135.

Line lineAsAxis = Line.CreateBound(placementPoint, 
					new XYZ(placementPoint.X,
					placementPoint.Y,
					placementPoint.Z + 1));

if (angle > 0)
{
	double angle_remainder = angle;
	while (angle_remainder > 0)
	{
		double rot_angle = 0;
		if (angle_remainder > 30)
			rot_angle = 30;
		else
			rot_angle = angle_remainder;

		ElementTransformUtils.RotateElement(doc, elevMarker.Id, lineAsAxis, rot_angle * App.TO_RADIANS);

		angle_remainder = angle_remainder - rot_angle;
	}
}

 

Message 11 of 11
jeremytammik
in reply to: grahamcook

Dear Graham,

 

Thank you for your updated and enhanced workaround.

 

I am glad to hear you have a workable solution while the code fix issue number is REVIT-134773 [RotateElement used on elevation marker adds 180 degrees -- 14258638] resolved.

 

I made a note of your solution on the blog, in case anyone else runs into a similar issue:

 

http://thebuildingcoder.typepad.com/blog/2018/08/wall-profile-command-update.html#5

 

Thank you very much for your patience and the creative stop-gap approach!

 

Best regards,

 

Jeremy

 



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

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