-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThumbnailViewCreateOrient.cs
More file actions
150 lines (99 loc) · 3.67 KB
/
Copy pathThumbnailViewCreateOrient.cs
File metadata and controls
150 lines (99 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Created by SharpDevelop.
* User: julianvenczel
* Date: 11/09/2017
* Time: 12:19 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
namespace ViewCreate
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("43688061-4DB0-4A42-A82B-68F6638C25AB")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void ViewCreate()
{
Document doc = this.ActiveUIDocument.Document;
// get a ViewFamilyType for a 3D View. created new instance of ViewFamilYType calle 'viewFamilyType'
ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(doc).
// Creates new filteredElementCollector to select all ViewFamilyTypes
OfClass(typeof(ViewFamilyType)).
Cast<ViewFamilyType>()
where v.ViewFamily == ViewFamily.ThreeDimensional
select v).First();
Categories categories = doc.Settings.Categories;
Category dim = categories.get_Item(BuiltInCategory.OST_Dimensions);
Category line = categories.get_Item(BuiltInCategory.OST_Lines);
XYZ eye = new XYZ(100,100,100);
XYZ forward = new XYZ(-1,1,-1);
XYZ up = new XYZ (-1,1,2);
ViewOrientation3D vOrient = new ViewOrientation3D(eye,up,forward);
using (Transaction t = new Transaction(doc,"Create view"))
{
t.Start();
View3D view = View3D.CreateIsometric(doc,viewFamilyType.Id);
view.get_Parameter(BuiltInParameter.MODEL_GRAPHICS_STYLE)
.Set(4);
view.SetOrientation(vOrient);
view.HideCategoryTemporary(dim.Id);
view.HideCategoryTemporary(line.Id);
view.SaveOrientationAndLock();
t.Commit();
}
}
public void SetVisStyle()
{
Document doc = this.ActiveUIDocument.Document;
View CurView = this.ActiveUIDocument.ActiveView;
using (Transaction t = new Transaction(doc, "Set View"))
{
t.Start();
CurView.get_Parameter(BuiltInParameter.MODEL_GRAPHICS_STYLE).Set(4);
t.Commit();
}
}
public void getOrientation()
{
Document doc = this.ActiveUIDocument.Document;
View currentView = this.ActiveUIDocument.ActiveView;
View3D v3D = (currentView as View3D);
ViewOrientation3D vOrient = v3D.GetOrientation();
XYZ eye = vOrient.EyePosition;
XYZ forward = vOrient.ForwardDirection;
XYZ up = vOrient.UpDirection;
String eyex = (eye.X).ToString();
String eyey = (eye.Y).ToString();
String eyez = (eye.Z).ToString();
String eyeXYZ = "eye orientation is \nX: " + eyex + "\nY: " + eyey + "\nZ: " + eyez;
String forwardx = (forward.X).ToString();
String forwardy = (forward.Y).ToString();
String forwardz = (forward.Z).ToString();
String forwardXYZ = "forward orientation is\nX: " + forwardx + "\nY: " + forwardy + "\nZ: " + forwardz;
String upx = (up.X).ToString();
String upy = (up.Y).ToString();
String upz = (up.Z).ToString();
String upXYZ = "up orientation is \nX: " + upx + "\nY: " + upy + "\nZ: " + upz;
TaskDialog.Show( "View Orientation", eyeXYZ + "\n" + forwardXYZ +"\n" + upXYZ );
}
}
}