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: 

Rotate a viewplan after creation

6 REPLIES 6
Reply
Message 1 of 7
daniel
1726 Views, 6 Replies

Rotate a viewplan after creation

Hi

I am trying to rotate the crobox of a view after creation, this means that I create the view and then activates the cropbox and makes it visible. Then I create a Boundingbox of the crop box. This box I get the rotation of and transforms.

The transformation is applied to the boundingbox, but when I uses this boundingbox as crop box on my view, the translation is back to the indentity matrix. This means that the translation is not applied.

codesnippet:

 

ViewPlan rotatetView = doc.GetElement(viewToDuplicate.Duplicate(ViewDuplicateOption.AsDependent)) as ViewPlan;

rotatetView.CropBoxActive = true;
rotatetView.CropBoxVisible = true;


BoundingBoxXYZ box = rotatetView.CropBox;

XYZ originOfRotation = (box.Max - box.Min) / 2;
XYZ axizOfRotation = XYZ.BasisZ;

Transform rotate = Transform.get_Rotation(originOfRotation, axizOfRotation, 180);
box.Transform = box.Transform.Multiply(rotate);

rotatetView.CropBox = box;

 

 

Any ideas how to fix this?
My goal is to create a set of rotated (userspesific angle) dependendt viewplans to be used to create fireplans.

 

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: daniel

Did you manage to find a solution to this problem?

I am having the same issue using the 2013 API and after some investigation have determined that the ViewPlan element does not accept modifications to its CropBox's Transform property.

I have tried directly assigning a newly created transform and then also assigning the result of multiplying the transorm with a rotation, both to no avail.

I then decided to replace the entire cropbox with a modified one and this was also fruitless.

By watching the values in the debugger I can see that if I grab a copy of the CropBox and modify its transform, the changes are propogated correctly. If I then assign this modified BoundingBoxXYZ object to the ViewPlan element the changes are ignored.

I have tried various methods of attack on this problem including first manually rotating a view to check whether the UI could shake loose any behind the scenes object state that could be preventing the modification and then attempted to further change its rotation using the API, still no dice.

Maybe it is possible that the ViewPlan element gathers the CropBox data from a seperate element such as the physical cropbox that can be interacted with on screen and that this is what should be changed (as is the case when manually performing this task in the UI)?

I may have just answered my own question (hopefully) and will investigate this next, but in the meantime does anyone have some insight into this issue?

Message 3 of 7
Anonymous
in reply to: daniel

Well I have solved the problem, in a way...

 

After some investigation I realised that I could achieve exactly what I wanted using the ViewSection element, thus avoiding the annoying ViewPlan element entirely :).

 

The ViewSection.CreateDetail method takes the desired bounding box (with the transorm already applied) as a parameter so there is no need to rotate after creation.

 

Still no idea why I couldn't rotate the ViewPlan element, but this is a good alternative for anyone in a similar situation.

 

An example of how to use ViewSection can be found in the CreateViewSection project in the SDK.

Message 4 of 7
daniel
in reply to: daniel

I have used that approach on some other methods earlier. The problem this time is that I need to create numerous duplicates of the same view plan, so that all evacuation routs in a building are correct way.

 

Still awaits answers from Autodesk support. 

Message 5 of 7
Ning_Zhou
in reply to: daniel

any answer from Autodesk? or already fixed in 2014?
Message 6 of 7
jeremytammik
in reply to: Ning_Zhou

Daniel, Sdwil2k5 and Ning,

Yes, this is resolved in Revit 2014, and possibly earlier versions as well.

I published some sample code demonstrating the process on The Building Coder:

http://thebuildingcoder.typepad.com/blog/2013/09/rotating-a-plan-view.html

 

I hope this works for you as well.

 

Best regards,

 

Jeremy



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

Message 7 of 7
Anonymous
in reply to: jeremytammik

Nice work Jeremy!

I will try it out as soon as I am able. Many thanks.

--
- Scott

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report