Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Fixed #29, #14, #12, started implementing schema 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Cominetti committed Jul 31, 2017
1 parent 3534a4a commit 8586631
Show file tree
Hide file tree
Showing 23 changed files with 895 additions and 529 deletions.
82 changes: 41 additions & 41 deletions Bcfier.Revit/Data/RevitView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static VisualizationInfo GenerateViewpoint(UIDocument uidoc)
}
//COMPONENTS PART
string versionName = doc.Application.VersionName;
v.Components = new List<Component>();
v.Components = new Components();

var visibleElems = new FilteredElementCollector(doc, doc.ActiveView.Id)
.WhereElementIsNotElementType()
Expand All @@ -157,49 +157,49 @@ public static VisualizationInfo GenerateViewpoint(UIDocument uidoc)

var selectedElems = uidoc.Selection.GetElementIds();


//TODO: FIX visibility/selection
//include only hidden elements and selected in the BCF
if (visibleElems.Count() > hiddenElems.Count())
{
foreach (var elem in hiddenElems)
{
v.Components.Add(new Component
{
OriginatingSystem = versionName,
IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem.Id)),
Visible = false,
Selected = false,
AuthoringToolId = elem.Id.IntegerValue.ToString()
});
}
foreach (var elem in selectedElems)
{
v.Components.Add(new Component
{
OriginatingSystem = versionName,
IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem)),
Visible = true,
Selected = true,
AuthoringToolId = elem.IntegerValue.ToString()
});
}
}
//if (visibleElems.Count() > hiddenElems.Count())
//{
// foreach (var elem in hiddenElems)
// {
// v.Components.Add(new Component
// {
// OriginatingSystem = versionName,
// IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem.Id)),
// Visible = false,
// Selected = false,
// AuthoringToolId = elem.Id.IntegerValue.ToString()
// });
// }
// foreach (var elem in selectedElems)
// {
// v.Components.Add(new Component
// {
// OriginatingSystem = versionName,
// IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem)),
// Visible = true,
// Selected = true,
// AuthoringToolId = elem.IntegerValue.ToString()
// });
// }
//}
//include only visible elements
//all the others are hidden
else
{
foreach (var elem in visibleElems)
{
v.Components.Add(new Component
{
OriginatingSystem = versionName,
IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem)),
Visible = true,
Selected = selectedElems.Contains(elem),
AuthoringToolId = elem.IntegerValue.ToString()
});
}
}
//else
//{
// foreach (var elem in visibleElems)
// {
// v.Components.Add(new Component
// {
// OriginatingSystem = versionName,
// IfcGuid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, elem)),
// Visible = true,
// Selected = selectedElems.Contains(elem),
// AuthoringToolId = elem.IntegerValue.ToString()
// });
// }
//}
return v;

}
Expand Down
92 changes: 46 additions & 46 deletions Bcfier.Revit/Entry/ExtEvntOpenView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void Execute(UIApplication app)
var cameraViewPoint = RevitUtils.GetRevitXYZ(v.OrthogonalCamera.CameraViewPoint);
var orient3D = RevitUtils.ConvertBasePoint(doc, cameraViewPoint, cameraDirection, cameraUpVector, true);


View3D orthoView = null;
//if active view is 3d ortho use it
if (doc.ActiveView.ViewType == ViewType.ThreeD)
Expand Down Expand Up @@ -175,52 +174,53 @@ public void Execute(UIApplication app)
else
return;

//TODO: FIX visibility/selection opening a view
//select/hide elements
if (v.Components != null && v.Components.Any())
{
var elementsToSelect = new List<ElementId>();
var elementsToHide = new List<ElementId>();
var elementsToShow = new List<ElementId>();

//Assuming that
var visibleElems = new FilteredElementCollector(doc, doc.ActiveView.Id)
.WhereElementIsNotElementType()
.WhereElementIsViewIndependent()
.ToElementIds()
.Where(e => doc.GetElement(e).CanBeHidden(doc.ActiveView)); //might affect performance, but it's necessary

foreach (var e in visibleElems)
{
//elements to select
var guid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, e));
if (v.Components.Any(x => x.IfcGuid == guid && x.Selected))
elementsToSelect.Add(e);

//elements to hide
if (v.Components.Any(x => x.IfcGuid == guid && !x.Visible))
elementsToHide.Add(e);

//elements to show //could be optional
if (v.Components.Any(x => x.IfcGuid == guid && x.Visible))
elementsToShow.Add(e);
}

using (var trans = new Transaction(uidoc.Document))
{
if (trans.Start("Show/Hide and select elements") == TransactionStatus.Started)
{
if (elementsToHide.Any())
doc.ActiveView.HideElementsTemporary(elementsToHide);
//there are no items to hide, therefore hide everything and just show the visible ones
else if (elementsToShow.Any())
doc.ActiveView.IsolateElementsTemporary(elementsToShow);

if (elementsToSelect.Any())
uidoc.Selection.SetElementIds(elementsToSelect);
}
trans.Commit();
}
}
//if (v.Components != null && v.Components.Any())
//{
// var elementsToSelect = new List<ElementId>();
// var elementsToHide = new List<ElementId>();
// var elementsToShow = new List<ElementId>();

// //Assuming that
// var visibleElems = new FilteredElementCollector(doc, doc.ActiveView.Id)
// .WhereElementIsNotElementType()
// .WhereElementIsViewIndependent()
// .ToElementIds()
// .Where(e => doc.GetElement(e).CanBeHidden(doc.ActiveView)); //might affect performance, but it's necessary

// foreach (var e in visibleElems)
// {
// //elements to select
// var guid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(doc, e));
// if (v.Components.Any(x => x.IfcGuid == guid && x.Selected))
// elementsToSelect.Add(e);

// //elements to hide
// if (v.Components.Any(x => x.IfcGuid == guid && !x.Visible))
// elementsToHide.Add(e);

// //elements to show //could be optional
// if (v.Components.Any(x => x.IfcGuid == guid && x.Visible))
// elementsToShow.Add(e);
// }

// using (var trans = new Transaction(uidoc.Document))
// {
// if (trans.Start("Show/Hide and select elements") == TransactionStatus.Started)
// {
// if (elementsToHide.Any())
// doc.ActiveView.HideElementsTemporary(elementsToHide);
// //there are no items to hide, therefore hide everything and just show the visible ones
// else if (elementsToShow.Any())
// doc.ActiveView.IsolateElementsTemporary(elementsToShow);

// if (elementsToSelect.Any())
// uidoc.Selection.SetElementIds(elementsToSelect);
// }
// trans.Commit();
// }
//}


uidoc.RefreshActiveView();
Expand Down
15 changes: 11 additions & 4 deletions Bcfier.Revit/RevitWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ private void OnOpenView(object sender, ExecutedRoutedEventArgs e)
return;
UIDocument uidoc = uiapp.ActiveUIDocument;

if (uidoc.ActiveView.ViewType == ViewType.Schedule)
{
MessageBox.Show("BCFier can't take snapshots of schedules.",
"Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}

if (uidoc.ActiveView.ViewType == ViewType.ThreeD)
{
var view3D = (View3D)uidoc.ActiveView;
Expand Down Expand Up @@ -116,11 +123,11 @@ private void OnAddView(object sender, ExecutedRoutedEventArgs e)
//get filename
UIDocument uidoc = uiapp.ActiveUIDocument;

if(uidoc.Document.Title!=null)
if (uidoc.Document.Title != null)
issue.Header[0].Filename = uidoc.Document.Title;
else
issue.Header[0].Filename = "Unknown";

Bcfier.SelectedBcf().HasBeenSaved = false;
}

Expand All @@ -133,7 +140,7 @@ private void OnAddView(object sender, ExecutedRoutedEventArgs e)
#endregion

#region private methods

/// <summary>
/// passing event to the user control
/// </summary>
Expand All @@ -153,6 +160,6 @@ private void RevitWindow_OnLoaded(object sender, RoutedEventArgs e)
StatHat.Post.EzCounter(@"[email protected]", "BCFierRevitStart", 1);
});
}

}
}
Loading

0 comments on commit 8586631

Please sign in to comment.