Skip to content

Commit

Permalink
update pick point
Browse files Browse the repository at this point in the history
  • Loading branch information
giobel committed Aug 16, 2021
1 parent 9a1afd2 commit d8da2e8
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions ReviTab/Buttons Tools/RevCloudsSelected.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public Result Execute(
// get elements from user selection
List<Element> selectedElements = new List<Element>();



foreach (Reference r in uidoc.Selection.PickObjects(ObjectType.Element))
{
Element e = doc.GetElement(r);
Expand All @@ -49,6 +51,9 @@ public Result Execute(
List<Curve> curvesSheet = new List<Curve>();
//THIS ONLY WORKS BY ACTIVATING THE VIEWPORT AND SELECTING THE ELEMENTS. AUTOMATICALLY FIND THE SELECTED ELEMENT VIEW -> TBC
ViewSheet selectedViewSheet = GetElementViewSheet(doc, doc.ActiveView);
ICollection<ElementId> linesToDelete = new List<ElementId>();

XYZ viewCenter = null;

foreach (Element e in selectedElements)
{
Expand Down Expand Up @@ -87,9 +92,23 @@ public Result Execute(
Categories groups = doc.Settings.Categories;
categoryToIsolate.Add(groups.get_Item(BuiltInCategory.OST_Loads).Id);

XYZ viewCenter = null;

XYZ changedVPcenter = null;

if (elementView.ViewType == ViewType.DraftingView)
{
t.Start("Draw center");

XYZ centerOnSheet = FlattenPoint(viewport.GetBoxCenter());

DetailCurve xCenter = doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(centerOnSheet, centerOnSheet+new XYZ(0.1,0,0)));
DetailCurve yCenter = doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(centerOnSheet, centerOnSheet + new XYZ(0, 0.1, 0)));
linesToDelete.Add(xCenter.Id);
linesToDelete.Add(yCenter.Id);
t.Commit();

}

t.Start("Hide Categories");

List<XYZ> pts = new List<XYZ>();
Expand Down Expand Up @@ -118,9 +137,13 @@ public Result Execute(
viewCenter = GetCentroid(pts, pts.Count);
}
else
{
{
//TaskDialog.Show("r", "View type is drafting");
viewCenter = uidoc.Selection.PickPoint();
if (viewCenter == null)
{
viewCenter = uidoc.Selection.PickPoint(ObjectSnapTypes.None, "Select center of View");
}


//pts.Add(uidoc.Selection.PickPoint());
}
Expand Down Expand Up @@ -258,15 +281,15 @@ public Result Execute(
//doc.Create.NewDetailCurve(doc.ActiveView, l);

//BBOX CENTER TO VIEW CENTER
doc.Create.NewDetailCurve(doc.ActiveView, Line.CreateBound(viewCenter, bboxCenter));
//doc.Create.NewDetailCurve(doc.ActiveView, Line.CreateBound(viewCenter, bboxCenter));

// SHEET 0,0,0 TO VIEWPORT CENTER
//doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(XYZ.Zero, new XYZ(changedVPcenter.X, changedVPcenter.Y, 0)));

//VIEWPORT CENTRE
//viewport.GetBoxCenter()
doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(new XYZ(0,0,0), FlattenPoint(vpCen)));
doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(new XYZ(0,0,0), FlattenPoint(viewport.GetBoxCenter())));
//doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(new XYZ(0,0,0), FlattenPoint(vpCen)));
//doc.Create.NewDetailCurve(selectedViewSheet, Line.CreateBound(new XYZ(0,0,0), FlattenPoint(viewport.GetBoxCenter())));

//INSIDE VIEW

Expand Down Expand Up @@ -299,8 +322,10 @@ public Result Execute(

t.Start("Draw Clouds on Sheet");


RevisionCloud cloudSheet = RevisionCloud.Create(doc, selectedViewSheet, rev[0], curvesSheet);

doc.Delete(linesToDelete);

t.Commit();
}
catch (Exception ex)
Expand Down

0 comments on commit d8da2e8

Please sign in to comment.