public void UpdateRevitProjectZone(FamilyInstance projectZone) { Document val = projectZone.get_Document(); Dimension[] associatedDimensions = m_AssociatedDimensions; foreach (Dimension val2 in associatedDimensions) { if (val2 != null) { val2.set_IsLocked(false); } } double westOffset = WestOffset; object westGrid = (object)WestGrid; double num = westOffset + ((westGrid != null) ? westGrid.get_Curve().GetEndPoint(0).get_X() : 0.0); double southOffset = SouthOffset; object southGrid = (object)SouthGrid; double num2 = southOffset + ((southGrid != null) ? southGrid.get_Curve().GetEndPoint(0).get_Y() : 0.0); XYZ val3 = new XYZ(num, num2, 0.0); double eastOffset = EastOffset; object eastGrid = (object)EastGrid; double num3 = eastOffset + ((eastGrid != null) ? eastGrid.get_Curve().GetEndPoint(0).get_X() : 0.0); double northOffset = NorthOffset; object northGrid = (object)NorthGrid; double num4 = northOffset + ((northGrid != null) ? northGrid.get_Curve().GetEndPoint(0).get_Y() : 0.0); double num5 = num3 - num; double num6 = num4 - num2; XYZ val4 = projectZone.get_Location().get_Point(); XYZ val5 = val3 - val4; ElementTransformUtils.MoveElement(val, projectZone.get_Id(), val5); projectZone.LookupParameter("Name").Set(Name); projectZone.LookupParameter("Top Level").Set(TopLevel.get_Id()); projectZone.LookupParameter("Base Level").Set(BaseLevel.get_Id()); projectZone.LookupParameter("Top Offset").Set(TopOffset); projectZone.LookupParameter("Base Offset").Set(BaseOffset); projectZone.LookupParameter("Length").Set(num5); projectZone.LookupParameter("Width").Set(num6); val.Regenerate(); ViewPlan viewForLevel = GetViewForLevel(BaseLevel); if (viewForLevel == null) { throw new Exception("No plan view exists for the base level of this project zone. A view must exist for dimensions to be created."); } Grid[] array = (Grid[])new Grid[4] { NorthGrid, SouthGrid, EastGrid, WestGrid }; double[] array2 = new double[4] { NorthOffset, SouthOffset, EastOffset, WestOffset }; Reference[] sideReferences = GetSideReferences(projectZone, viewForLevel); Reference[] gridReferences = GetGridReferences(array, viewForLevel); for (int j = 0; j < 4; j++) { if (m_AssociatedDimensions[j] != null) { bool flag = false; if (array[j] != null) { foreach (Reference reference in m_AssociatedDimensions[j].get_References()) { Reference val6 = reference; ElementId val7 = val6.get_ElementId(); if (val7 == array[j].get_Id()) { flag = true; } } } if (!flag) { val.Delete(m_AssociatedDimensions[j].get_Id()); m_AssociatedDimensions[j] = null; } if (m_AssociatedDimensions[j] != null && !m_AssociatedDimensions[j].get_Value().HasValue&& (array2[j] >= 1E-09 || array2[j] <= 1E-09)) { val.Delete(m_AssociatedDimensions[j].get_Id()); m_AssociatedDimensions[j] = null; } } if (array[j] != null && m_AssociatedDimensions[j] == null) { if (array2[j] >= 1E-09 || array2[j] <= -1E-09) { ReferenceArray val8 = new ReferenceArray(); val8.Append(sideReferences[j]); val8.Append(gridReferences[j]); Line val9 = CreateDimensionLine(projectZone, (Directions)j, array2[j]); m_AssociatedDimensions[j] = val.get_Create().NewDimension(viewForLevel, val9, val8); } else { m_AssociatedDimensions[j] = val.get_Create().NewAlignment(viewForLevel, sideReferences[j], gridReferences[j]); } } } Dimension[] associatedDimensions2 = m_AssociatedDimensions; foreach (Dimension val10 in associatedDimensions2) { if (val10 != null) { val10.set_IsLocked(true); } } }
public Element CreateRevitProjectZone(Document doc) { double westOffset = WestOffset; object westGrid = (object)WestGrid; double num = westOffset + ((westGrid != null) ? westGrid.get_Curve().GetEndPoint(0).get_X() : 0.0); double southOffset = SouthOffset; object southGrid = (object)SouthGrid; double num2 = southOffset + ((southGrid != null) ? southGrid.get_Curve().GetEndPoint(0).get_Y() : 0.0); XYZ val = new XYZ(num, num2, 0.0); double eastOffset = EastOffset; object eastGrid = (object)EastGrid; double num3 = eastOffset + ((eastGrid != null) ? eastGrid.get_Curve().GetEndPoint(0).get_X() : 0.0); double northOffset = NorthOffset; object northGrid = (object)NorthGrid; double num4 = northOffset + ((northGrid != null) ? northGrid.get_Curve().GetEndPoint(0).get_Y() : 0.0); double num5 = num3 - num; double num6 = num4 - num2; FamilySymbol revitZoneSymbol = GetRevitZoneSymbol(doc); FamilyInstance val2 = doc.get_Create().NewFamilyInstance(val, revitZoneSymbol, BaseLevel, 0); val2.LookupParameter("Name").Set(Name); val2.LookupParameter("Top Level").Set(TopLevel.get_Id()); val2.LookupParameter("Top Offset").Set(TopOffset); val2.LookupParameter("Base Offset").Set(BaseOffset); val2.LookupParameter("Length").Set(num5); val2.LookupParameter("Width").Set(num6); doc.Regenerate(); UniqueId = val2.get_UniqueId(); ViewPlan viewForLevel = GetViewForLevel(BaseLevel); if (viewForLevel == null) { throw new Exception("No plan view exists for the base level of this project zone. A view must exist for dimensions to be created."); } Grid[] array = (Grid[])new Grid[4] { NorthGrid, SouthGrid, EastGrid, WestGrid }; double[] array2 = new double[4] { NorthOffset, SouthOffset, EastOffset, WestOffset }; Reference[] sideReferences = GetSideReferences(val2, viewForLevel); Reference[] gridReferences = GetGridReferences(array, viewForLevel); for (int i = 0; i < 4; i++) { if (array[i] != null) { if (array2[i] >= 1E-09 || array2[i] <= -1E-09) { ReferenceArray val3 = new ReferenceArray(); val3.Append(sideReferences[i]); val3.Append(gridReferences[i]); Line val4 = CreateDimensionLine(val2, (Directions)i, array2[i]); Dimension val5 = doc.get_Create().NewDimension(viewForLevel, val4, val3); val5.set_IsLocked(true); } else { doc.get_Create().NewAlignment(viewForLevel, sideReferences[i], gridReferences[i]); } } } return(val2); }