/// <summary> /// update current Sketch3D using current UCS and settings /// </summary> private void UpdateSketch3D() { if (m_displayKind == DisplayKinds.GeometryModel) { GeometryData geomFactory; if (m_isSelectView) { geomFactory = new GeometryData(m_selected, m_currentView); m_detailLevel = ViewDetailLevel.Undefined; } else { geomFactory = new GeometryData(m_selected, m_detailLevel, m_currentView); } Graphics3DData geom3DData = geomFactory.Data3D; Graphics3DData old3DData = m_currentSketch3D.Data3D; geom3DData.CurrentUCS = old3DData.CurrentUCS; m_currentSketch3D.Data3D = geom3DData; m_currentSketch3D.Data2D = Graphics2DData.Empty; } else if (m_displayKind == DisplayKinds.AnalyticalModel) { ModelData modelFactory = new ModelData(m_selected); Graphics3DData model3DData = modelFactory.Data3D; Graphics2DData model2DData = modelFactory.Data2D; Graphics3DData old3DData = m_currentSketch3D.Data3D; model3DData.CurrentUCS = old3DData.CurrentUCS; m_currentSketch3D.Data3D = model3DData; m_currentSketch3D.Data2D = model2DData; } }
/// <summary> /// constructor /// </summary> public ObjectViewer() { UIDocument doc = Command.CommandData.Application.ActiveUIDocument; ElementSet selection = new ElementSet(); foreach (ElementId elementId in doc.Selection.GetElementIds()) { selection.Insert(doc.Document.GetElement(elementId)); } // only one element should be selected if (0 == selection.Size) { throw new ErrorMessageException("Please select an element."); } if (1 < selection.Size) { throw new ErrorMessageException("Please select only one element."); } // get selected element foreach (Element e in selection) { m_selected = e; } // get current view and all views m_currentView = doc.Document.ActiveView; FilteredElementIterator itor = (new FilteredElementCollector(doc.Document)).OfClass(typeof(View)).GetElementIterator(); itor.Reset(); while (itor.MoveNext()) { View view = itor.Current as View; // Skip view templates because they're invisible in project browser, invalid for geometry elements if (null != view && !view.IsTemplate) { m_allViews.Add(view); } } // create a instance of Sketch3D GeometryData geomFactory = new GeometryData(m_selected, m_currentView); m_currentSketch3D = new Sketch3D(geomFactory.Data3D, Graphics2DData.Empty); //get a instance of ParametersFactory and then use it to create Parameters ParasFactory parasFactory = new ParasFactory(m_selected); m_paras = parasFactory.CreateParas(); }
private Element m_selected; // selected element to display #endregion Fields #region Constructors /// <summary> /// constructor /// </summary> public ObjectViewer() { UIDocument doc = Command.CommandData.Application.ActiveUIDocument; ElementSet selection = doc.Selection.Elements; // only one element should be selected if (0 == selection.Size) { throw new ErrorMessageException("Please select an element."); } if (1 < selection.Size) { throw new ErrorMessageException("Please select only one element."); } // get selected element foreach (Element e in selection) { m_selected = e; } // get current view and all views m_currentView = doc.Document.ActiveView; FilteredElementIterator itor = (new FilteredElementCollector(doc.Document)).OfClass(typeof(View)).GetElementIterator(); itor.Reset(); while (itor.MoveNext()) { View view = itor.Current as View; // Skip view templates because they're invisible in project browser, invalid for geometry elements if (null != view && !view.IsTemplate) { m_allViews.Add(view); } } // create a instance of Sketch3D GeometryData geomFactory = new GeometryData(m_selected, m_currentView); m_currentSketch3D = new Sketch3D(geomFactory.Data3D, Graphics2DData.Empty); //get a instance of ParametersFactory and then use it to create Parameters ParasFactory parasFactory = new ParasFactory(m_selected); m_paras = parasFactory.CreateParas(); }
/// <summary> /// update current Sketch3D using current UCS and settings /// </summary> private void UpdateSketch3D() { if (m_displayKind == DisplayKinds.GeometryModel) { GeometryData geomFactory; if(m_isSelectView) { geomFactory = new GeometryData(m_selected, m_currentView); m_detailLevel = DetailLevels.Undefined; } else { geomFactory = new GeometryData(m_selected, m_detailLevel, m_currentView); } Graphics3DData geom3DData = geomFactory.Data3D; Graphics3DData old3DData = m_currentSketch3D.Data3D; geom3DData.CurrentUCS = old3DData.CurrentUCS; m_currentSketch3D.Data3D = geom3DData; m_currentSketch3D.Data2D = Graphics2DData.Empty; } else if (m_displayKind == DisplayKinds.AnalyticalModel) { ModelData modelFactory = new ModelData(m_selected); Graphics3DData model3DData = modelFactory.Data3D; Graphics2DData model2DData = modelFactory.Data2D; Graphics3DData old3DData = m_currentSketch3D.Data3D; model3DData.CurrentUCS = old3DData.CurrentUCS; m_currentSketch3D.Data3D = model3DData; m_currentSketch3D.Data2D = model2DData; } }