Stream(ArrayList data, PointOnFace ptOnFace) { data.Add(new Snoop.Data.ClassSeparator(typeof(PointOnFace))); data.Add(new Snoop.Data.Object("Reference", ptOnFace.GetFaceReference())); data.Add(new Snoop.Data.Uv("UV", ptOnFace.UV)); }
Stream(ArrayList data, PointElementReference ptElemRef) { data.Add(new Snoop.Data.ClassSeparator(typeof(PointElementReference))); PointOnEdge ptOnEdge = ptElemRef as PointOnEdge; if (ptOnEdge != null) { Stream(data, ptOnEdge); return; } PointOnEdgeEdgeIntersection ptOnEdgeEdgeInt = ptElemRef as PointOnEdgeEdgeIntersection; if (ptOnEdgeEdgeInt != null) { Stream(data, ptOnEdgeEdgeInt); return; } PointOnEdgeFaceIntersection ptOnEdgeFaceInt = ptElemRef as PointOnEdgeFaceIntersection; if (ptOnEdgeFaceInt != null) { Stream(data, ptOnEdgeFaceInt); return; } PointOnFace ptOnFace = ptElemRef as PointOnFace; if (ptOnFace != null) { Stream(data, ptOnFace); return; } //PointOnSketch ptOnSketch = ptElemRef as PointOnSketch; //if (ptOnSketch != null) { // Stream(data, ptOnSketch); // return; //} //PointRelativeToPoint ptRelToPt = ptElemRef as PointRelativeToPoint; //if (ptRelToPt != null) { // Stream(data, ptRelToPt); // return; //} }
public void Execute(UIApplication uiapp) { try { UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; using (Transaction tx = new Transaction(doc)) { tx.Start("EE06_PlaceFamily"); FamilySymbol myFamilySymbol_Platform = myMethod_CheckExistanceOfFamily(doc, myString_Family_Platform, myString_Type_Platform); if (myFamilySymbol_Platform == null) { return; } FamilySymbol myFamilySymbol_Chair = null; if (myBool_AlsoPlaceAChair) { myFamilySymbol_Chair = myMethod_CheckExistanceOfFamily(doc, myString_Family_Chair, myString_Type_Chair); if (myFamilySymbol_Chair == null) { return; } } Reference pickedRef = null; try { pickedRef = uiapp.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.PointOnElement, "Please select a Face"); } #region catch and finally catch (Exception ex) { } finally { } #endregion if (pickedRef == null) { return; } FamilyInstance myFamilyInstance_New = doc.Create.NewFamilyInstance(XYZ.Zero, myFamilySymbol_Platform, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); doc.Regenerate(); IList <ElementId> placePointIds_1338 = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(myFamilyInstance_New); ReferencePoint myReferencePoint_Centre = doc.GetElement(placePointIds_1338.First()) as ReferencePoint; UV point_in_3d_UV = pickedRef.UVPoint; PointOnFace myPointOnFace = uidoc.Application.Application.Create.NewPointOnFace(pickedRef, point_in_3d_UV); myReferencePoint_Centre.SetPointElementReference(myPointOnFace); doc.Regenerate(); myReferencePoint_Centre.get_Parameter(BuiltInParameter.POINT_ELEMENT_DRIVEN).Set(0); ElementTransformUtils.MoveElement(doc, myReferencePoint_Centre.Id, myReferencePoint_Centre.GetCoordinateSystem().OfPoint(new XYZ(0, 0, 0.1)) - myReferencePoint_Centre.Position); if (myFamilySymbol_Chair != null) { GeometryElement myGeomeryElement = myFamilyInstance_New.get_Geometry(new Options() { ComputeReferences = true }); GeometryInstance myGeometryInstance = myGeomeryElement.First() as GeometryInstance; GeometryElement myGeomeryElementSymbol = myGeometryInstance.GetSymbolGeometry(); GeometryObject myGeometryObject = myGeomeryElementSymbol.Where(x => (x as Solid) != null).First(); PlanarFace myPlanarFace = ((Solid)myGeometryObject).Faces.get_Item(0) as PlanarFace; doc.Create.NewFamilyInstance(myPlanarFace, myReferencePoint_Centre.Position, myReferencePoint_Centre.GetCoordinateSystem().OfVector(new XYZ(1, 0, 0)), myFamilySymbol_Chair); } tx.Commit(); uidoc.Selection.SetElementIds(new List <ElementId>() { myReferencePoint_Centre.Id }); myWindow1.mySelectMethod(myIntUPDown); myIntUPDown.Value = myFamilyInstance_New.Id.IntegerValue; } myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisZ, false); myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisX, false); myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisY, true); } #region catch and finally catch (Exception ex) { _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE06_PlaceFamily" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true); } finally { } #endregion }
public void Execute(UIApplication uiapp) { try { UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; // myListView_ALL_Fam_Master.Items.Add(doc.GetElement(uidoc.Selection.GetElementIds().First()).Name); FamilyInstance myFamilyInstance_Middle2 = doc.GetElement(new ElementId(myWindow1.myIntUpDown_Middle2.Value.Value)) as FamilyInstance; IList <ElementId> placePointIds_1339 = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(myFamilyInstance_Middle2); ReferencePoint myReferencePoint_Middle = doc.GetElement(placePointIds_1339.First()) as ReferencePoint; FamilyInstance myFamilyInstance_Departure = doc.GetElement(new ElementId(myWindow1.myToolKit_IntUpDown.Value.Value)) as FamilyInstance; IList <ElementId> placePointIds_1338 = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(myFamilyInstance_Departure); ReferencePoint myReferencePoint_Centre = doc.GetElement(placePointIds_1338.First()) as ReferencePoint; Transform myTransform = myReferencePoint_Centre.GetCoordinateSystem(); Transform myTransform_ToMakeTheRotationRelative; if (true) { double myDouble_AngleToBasis = XYZ.BasisZ.AngleTo(myTransform.BasisZ); //2 places line , 3 places method switch (myWindow1.mySlider.Name) { case "mySlider_Rotate_BasisY": myDouble_AngleToBasis = XYZ.BasisY.AngleTo(myTransform.BasisY); //2 places line , 3 places method break; case "mySlider_Rotate_BasisX": myDouble_AngleToBasis = XYZ.BasisX.AngleTo(myTransform.BasisX); //2 places line , 3 places method break; } if (IsZero(myDouble_AngleToBasis)) { myTransform_ToMakeTheRotationRelative = Transform.Identity; } else { XYZ axis = myTransform.BasisZ.CrossProduct(-XYZ.BasisZ); //2 places line , 3 places method, normally (z) negative switch (myWindow1.mySlider.Name) { case "mySlider_Rotate_BasisY": axis = myTransform.BasisY.CrossProduct(-XYZ.BasisY); //2 places line , 3 places method, normally (z) negative break; case "mySlider_Rotate_BasisX": axis = myTransform.BasisX.CrossProduct(-XYZ.BasisX); //2 places line , 3 places method, normally (z) negative break; } myTransform_ToMakeTheRotationRelative = Transform.CreateRotationAtPoint(axis, myDouble_AngleToBasis, XYZ.Zero); } } double myDouble = -2.4; for (int i = 0; i < 25; i++) { myWindow1.myListTransform.Add(new Transform(myTransform) { Origin = myTransform.Origin /*+ new XYZ(myDouble, 0, 0)*/ }); myDouble = myDouble + 0.2; } int myIntTimeOut = 0; int myInt_ChangeCount = 0; double myDouble_ChangePosition = -1; using (TransactionGroup transGroup = new TransactionGroup(doc)) { transGroup.Start("Transform animation 2"); bool myBool_Perform_Unhost_And_Rehost = true; if (myReferencePoint_Centre.GetPointElementReference() == null) { myBool_Perform_Unhost_And_Rehost = false; } PointOnFace myPointOnFace = (PointOnFace)myReferencePoint_Centre.GetPointElementReference(); if (myBool_Perform_Unhost_And_Rehost) { using (Transaction y = new Transaction(doc, "Remove Hosting")) { y.Start(); myReferencePoint_Centre.get_Parameter(BuiltInParameter.POINT_ELEMENT_DRIVEN).Set(0); y.Commit(); } } while (myWindow1.mySlideInProgress) { wait(100); myIntTimeOut++; if (myDouble_ChangePosition != myWindow1.mySlider.Value) { myDouble_ChangePosition = myWindow1.mySlider.Value; myWindow1.myLabel_ChangeCount.Content = myInt_ChangeCount++.ToString(); using (Transaction y = new Transaction(doc, "a Transform")) { y.Start(); double myDoubleRotateAngle = ((Math.PI * 2) / 24) * myDouble_ChangePosition; Transform myTransform_Rotate = Transform.CreateRotationAtPoint(XYZ.BasisZ, Math.PI + -myDoubleRotateAngle, XYZ.Zero); //1 places line and DOUBLE normally (z) negative , 3 places method switch (myWindow1.mySlider.Name) { case "mySlider_Rotate_BasisY": myTransform_Rotate = Transform.CreateRotationAtPoint(XYZ.BasisY, Math.PI + -myDoubleRotateAngle, XYZ.Zero); //1 places line and DOUBLE normally (z) negative , 3 places method myBool_Perform_Unhost_And_Rehost = false; break; case "mySlider_Rotate_BasisX": myTransform_Rotate = Transform.CreateRotationAtPoint(XYZ.BasisX, Math.PI + -myDoubleRotateAngle, XYZ.Zero); //1 places line and DOUBLE normally (z) negative , 3 places method myBool_Perform_Unhost_And_Rehost = false; break; } Transform myTransform_Temp = Transform.Identity; myTransform_Temp.Origin = myReferencePoint_Centre.GetCoordinateSystem().Origin; myTransform_Temp.BasisX = myTransform_ToMakeTheRotationRelative.OfVector(myTransform_Rotate.BasisX); myTransform_Temp.BasisY = myTransform_ToMakeTheRotationRelative.OfVector(myTransform_Rotate.BasisY); myTransform_Temp.BasisZ = myTransform_ToMakeTheRotationRelative.OfVector(myTransform_Rotate.BasisZ); myReferencePoint_Centre.SetCoordinateSystem(myTransform_Temp); if (myBool_InterpolateMiddle_WhenEitherA_or_B) { myWindow1.myMethod_whichTook_120Hours_OfCoding(); myReferencePoint_Middle.SetCoordinateSystem(myWindow1.myListTransform_Interpolate[(int)myWindow1.mySlider_Interpolate.Value]); } y.Commit(); myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisZ, false); myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisX, false); myWindow1.setSlider(myWindow1.myIntUpDown_Middle2, myWindow1.mySlider_Rotate_BasisY, true); } } myWindow1.myLabel_Setting.Content = myWindow1.mySlider.Value.ToString(); if (myIntTimeOut == 400) { MessageBox.Show("Timeout"); break; } } transGroup.Assimilate(); } } #region catch and finally catch (Exception ex) { _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE03_RotateAroundBasis" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true); } finally { } #endregion }