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);

                if (doc.ActiveView.GetType() != typeof(View3D))
                {
                    MessageBox.Show("ActiveView is not typeof View3D.");
                    return;
                }

                FamilyInstance myFamilyInstance_NerfGun = null;
                if (uidoc.Selection.GetElementIds().Count == 0)
                {
                    string myString_RememberLast = doc.ProjectInformation.get_Parameter(BuiltInParameter.PROJECT_NUMBER).AsString();
                    int    n;
                    if (int.TryParse(myString_RememberLast, out n))
                    {
                        myFamilyInstance_NerfGun = doc.GetElement(new ElementId(n)) as FamilyInstance;
                    }
                }
                else
                {
                    myFamilyInstance_NerfGun = doc.GetElement(uidoc.Selection.GetElementIds().First()) as FamilyInstance;
                }


                if (myFamilyInstance_NerfGun == null)
                {
                    MessageBox.Show("Please perform step 5 of 19 first." + Environment.NewLine + Environment.NewLine + "(Placing Nerf Gun)");
                    return;
                }

                ///            TECHNIQUE 14 OF 19 (EE14_Draw3D_IntersectorLines.cs)
                ///↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ DRAW INTERSECTOR LINES FROM NERF GUN ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                ///
                /// Interfaces and ENUM's:
                ///     BuiltInParameter.POINT_ELEMENT_DRIVEN
                ///     IFailuresPreprocessor
                ///
                ///
                /// Demonstrates classes:
                ///     ReferencePoint
                ///     AdaptiveComponentInstanceUtils
                ///     Transform
                ///     TransactionGroup
                ///     Random*
                ///     ElementMulticategoryFilter
                ///     ReferenceIntersector
                ///
                ///
                /// Key methods:
                ///     AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(
                ///     myReferencePoint.GetCoordinateSystem(
                ///     refIntersector.FindNearest(
                ///     myReferenceWithContext.GetReference(
                ///     uidoc.RefreshActiveView();
                ///
                ///
                ///
                /// * class is actually part of the .NET framework (not Revit API)
                ///
                ///
                ///	https://github.com/joshnewzealand/Revit-API-Playpen-CSharp

                uidoc.Selection.SetElementIds(new List <ElementId>());

                ReferencePoint myReferencePoint = doc.GetElement(AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(myFamilyInstance_NerfGun).First()) as ReferencePoint;

                Transform myTransform_FromNurfGun = myReferencePoint.GetCoordinateSystem();


                using (TransactionGroup transGroup = new TransactionGroup(doc))
                {
                    transGroup.Start("Transaction Group");

                    if (!myReferencePoint.get_Parameter(BuiltInParameter.POINT_ELEMENT_DRIVEN).IsReadOnly)
                    {
                        using (Transaction tx = new Transaction(doc))
                        {
                            tx.Start("Unhost");

                            myReferencePoint.get_Parameter(BuiltInParameter.POINT_ELEMENT_DRIVEN).Set(0);

                            tx.Commit();
                            uidoc.RefreshActiveView();
                        }
                    }

                    MyPreProcessor preproccessor = new MyPreProcessor();

                    for (int i = 1; i <= 100; i++)
                    {
                        if (i > 100)
                        {
                            MessageBox.Show("Stopped at 'i > 100' because more will cause Revit to 'freeze up'.");
                            break;
                        }

                        Random rnd = new Random();
                        OverrideGraphicSettings ogs = new OverrideGraphicSettings();
                        ogs.SetProjectionLineColor(new Autodesk.Revit.DB.Color((byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256)));

                        using (Transaction tx = new Transaction(doc))
                        {
                            FailureHandlingOptions options = tx.GetFailureHandlingOptions();
                            options.SetFailuresPreprocessor(preproccessor);
                            tx.SetFailureHandlingOptions(options);

                            tx.Start("Splatter Gun");

                            Line myLine_BasisX = Line.CreateUnbound(myTransform_FromNurfGun.Origin, myTransform_FromNurfGun.BasisX);
                            myReferencePoint.Location.Rotate(myLine_BasisX, GetRandomNumber());

                            Line myLine_BasisZ = Line.CreateUnbound(myTransform_FromNurfGun.Origin, myTransform_FromNurfGun.BasisZ);
                            myReferencePoint.Location.Rotate(myLine_BasisZ, GetRandomNumber());

                            myTransform_FromNurfGun = myReferencePoint.GetCoordinateSystem();

                            List <BuiltInCategory> builtInCats = new List <BuiltInCategory>();
                            builtInCats.Add(BuiltInCategory.OST_Roofs);
                            builtInCats.Add(BuiltInCategory.OST_Ceilings);
                            builtInCats.Add(BuiltInCategory.OST_Floors);
                            builtInCats.Add(BuiltInCategory.OST_Walls);
                            builtInCats.Add(BuiltInCategory.OST_Doors);
                            builtInCats.Add(BuiltInCategory.OST_Windows);
                            builtInCats.Add(BuiltInCategory.OST_CurtainWallPanels);
                            builtInCats.Add(BuiltInCategory.OST_CurtainWallMullions);

                            ElementMulticategoryFilter intersectFilter = new ElementMulticategoryFilter(builtInCats);
                            ReferenceIntersector       refIntersector  = new ReferenceIntersector(intersectFilter, FindReferenceTarget.Face, doc.ActiveView as View3D);

                            ReferenceWithContext myReferenceWithContext = refIntersector.FindNearest(myTransform_FromNurfGun.Origin, myTransform_FromNurfGun.BasisZ);

                            if (myReferenceWithContext != null)
                            {
                                Reference myReferenceHosting_Normal = myReferenceWithContext.GetReference();

                                Element myElement_ContainingFace = doc.GetElement(myReferenceHosting_Normal.ElementId);
                                Face    myFace = myElement_ContainingFace.GetGeometryObjectFromReference(myReferenceHosting_Normal) as Face;
                                if (myFace.GetType() != typeof(PlanarFace))
                                {
                                    return;                                        // continue;
                                }
                                Plane       plane       = Plane.CreateByNormalAndOrigin(myTransform_FromNurfGun.BasisX, myTransform_FromNurfGun.Origin);
                                SketchPlane sketchPlane = SketchPlane.Create(doc, plane);

                                if (myTransform_FromNurfGun.Origin.DistanceTo(myReferenceHosting_Normal.GlobalPoint) > 0.0026)//minimum lenth check
                                {
                                    Line line = Line.CreateBound(myTransform_FromNurfGun.Origin, myReferenceHosting_Normal.GlobalPoint);

                                    ModelLine myModelLine = doc.Create.NewModelCurve(line, sketchPlane) as ModelLine;

                                    doc.ActiveView.SetElementOverrides(myModelLine.Id, ogs);

                                    myWindow1.myListElementID_SketchPlanesToDelete.Add(sketchPlane.Id);

                                    Transform myXYZ_FamilyTransform = Transform.Identity;

                                    if (myReferenceHosting_Normal.ConvertToStableRepresentation(doc).Contains("INSTANCE"))
                                    {
                                        myXYZ_FamilyTransform = (myElement_ContainingFace as FamilyInstance).GetTotalTransform();
                                    }

                                    PlanarFace myPlanarFace = myFace as PlanarFace;

                                    Transform myTransform = Transform.Identity;
                                    myTransform.Origin = myReferenceHosting_Normal.GlobalPoint;
                                    myTransform.BasisX = myXYZ_FamilyTransform.OfVector(myPlanarFace.XVector);
                                    myTransform.BasisY = myXYZ_FamilyTransform.OfVector(myPlanarFace.YVector);
                                    myTransform.BasisZ = myXYZ_FamilyTransform.OfVector(myPlanarFace.FaceNormal);

                                    SketchPlane mySketchPlane = SketchPlane.Create(doc, myReferenceHosting_Normal);

                                    // Create a geometry circle in Revit application
                                    XYZ    xVec        = myTransform.OfVector(XYZ.BasisX);
                                    XYZ    yVec        = myTransform.OfVector(XYZ.BasisY);
                                    double startAngle2 = 0;
                                    double endAngle2   = 2 * Math.PI;
                                    double radius2     = 1.23;
                                    Arc    geomPlane3  = Arc.Create(myTransform.OfPoint(new XYZ(0, 0, 0)), radius2, startAngle2, endAngle2, xVec, yVec);

                                    ModelArc arc = doc.Create.NewModelCurve(geomPlane3, mySketchPlane) as ModelArc;
                                    //doc.Delete(sketch2.Id);

                                    doc.ActiveView.SetElementOverrides(arc.Id, ogs);
                                }
                            }
                            tx.Commit();
                            uidoc.RefreshActiveView();
                        }
                    }
                    transGroup.Assimilate();
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE05_Part1" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true);
            }
            finally
            {
            }
            #endregion
        }
Beispiel #2
0
        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;
                        }
                    }
                    Level     myLevel   = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().First() as Level;
                    Reference pickedRef = null;
                    XYZ       myXYZ     = null;
                    try
                    {
                        SketchPlane sp = SketchPlane.Create(doc, myLevel.GetPlaneReference());
                        doc.ActiveView.SketchPlane = sp;

                        // doc.ActiveView.ShowActiveWorkPlane();

                        //clearing existing command
                        SetForegroundWindow(uidoc.Application.MainWindowHandle);

                        myXYZ     = uiapp.ActiveUIDocument.Selection.PickPoint();
                        pickedRef = sp.GetPlaneReference();
                        //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;
                    UV           point_in_3d_UV = new UV(myXYZ.X, myXYZ.Y);
                    PointOnPlane myPointOnPlane = uidoc.Application.Application.Create.NewPointOnPlane(doc.ActiveView.SketchPlane.GetPlaneReference(), point_in_3d_UV, UV.BasisU, 0.0);

                    myReferencePoint_Centre.SetPointElementReference(myPointOnPlane);

                    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
        }
Beispiel #3
0
        public void Execute(UIApplication uiapp)
        {
            try
            {
                UIDocument uidoc = uiapp.ActiveUIDocument;
                Document   doc   = uidoc.Document;

                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();

                int    myIntTimeOut            = 0;
                int    myInt_ChangeCount       = 0;
                double myDouble_ChangePosition = -1;

                using (TransactionGroup transGroup = new TransactionGroup(doc))
                {
                    transGroup.Start("EE05_Move");

                    if (!myReferencePoint_Centre.get_Parameter(BuiltInParameter.POINT_ELEMENT_DRIVEN).IsReadOnly)
                    {
                        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 = myDouble_ChangePosition;

                                Transform myTransform_Temp = Transform.Identity;

                                myTransform_Temp.BasisX = myTransform.BasisX;
                                myTransform_Temp.BasisY = myTransform.BasisY;
                                myTransform_Temp.BasisZ = myTransform.BasisZ;

                                switch (myWindow1.mySlider.Name)
                                {
                                case "mySlider_Move_X":
                                    myTransform_Temp.Origin = myTransform.Origin + new XYZ(myDoubleRotateAngle, 0, 0);
                                    break;

                                case "mySlider_Move_Y":
                                    myTransform_Temp.Origin = myTransform.Origin + new XYZ(0, myDoubleRotateAngle, 0);
                                    break;

                                case "mySlider_Move_Z":
                                    myTransform_Temp.Origin = myTransform.Origin + new XYZ(0, 0, myDoubleRotateAngle);
                                    break;
                                }

                                myReferencePoint_Centre.SetCoordinateSystem(myTransform_Temp);

                                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);

                                y.Commit();
                            }
                        }

                        myWindow1.myLabel_Setting.Content = myWindow1.mySlider.Value.ToString();

                        if (myIntTimeOut == 400)
                        {
                            MessageBox.Show("Timeout");
                            break;
                        }
                    }

                    transGroup.Assimilate();
                }

                myWindow1.mySlider.Value = 0;
            }

            #region catch and finally
            catch (Exception ex)
            {
                _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE05_Move" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true);
            }
            finally
            {
            }
            #endregion
        }
Beispiel #4
0
        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_Departure = doc.GetElement(new ElementId(myWindow1.myIntUpDown_Middle2.Value.Value)) as FamilyInstance;
                FamilySymbol   myFamilySymbol             = doc.GetElement(myFamilyInstance_Departure.GetTypeId()) as FamilySymbol;

                IList <ElementId> placePointIds_1338         = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(myFamilyInstance_Departure);
                ReferencePoint    myReferencePoint_Departure = doc.GetElement(placePointIds_1338.First()) as ReferencePoint;

                Transform myTransform = myReferencePoint_Departure.GetCoordinateSystem();

                int    myIntTimeOut            = 0;
                int    myInt_ChangeCount       = 0;
                double myDouble_ChangePosition = -1;


                ///                  TECHNIQUE 6 OF 19
                ///↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ SET DEFAULT TYPE ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                ///Demonstrates:
                ///SketchPlane
                ///PromptForFamilyInstancePlacement with the PromptForFamilyInstancePlacementOptions class
                ///DocumentChanged event that cancels the command and focuses the window


                using (TransactionGroup transGroup = new TransactionGroup(doc))
                {
                    transGroup.Start("Transform animation");

                    if (myBool_Cycle)
                    {
                        for (int i = 1; i <= myWindow1.myUpDown_CycleNumber.Value; i++)
                        {
                            for (int ii = 0; ii <= 24; ii++)
                            {
                                wait(100);
                                if (true) //candidate for methodisation 202006141254
                                {
                                    if (myDouble_ChangePosition != ii)
                                    {
                                        myDouble_ChangePosition = ii;
                                        myWindow1.myLabel_ChangeCount.Content = myInt_ChangeCount++.ToString();
                                        using (Transaction y = new Transaction(doc, "a Transform"))
                                        {
                                            y.Start();

                                            myReferencePoint_Departure.SetCoordinateSystem(myWindow1.myListTransform_Interpolate[(int)myDouble_ChangePosition]);

                                            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 = ii.ToString();
                            }
                        }
                    }

                    if (!myBool_Cycle)
                    {
                        while (myWindow1.mySlideInProgress | myBool_RunOnce == true)
                        {
                            myBool_RunOnce = false;
                            wait(100); myIntTimeOut++;

                            if (true) //candidate for methodisation 202006141254
                            {
                                if (myDouble_ChangePosition != myWindow1.mySlider_Interpolate.Value)
                                {
                                    myDouble_ChangePosition = myWindow1.mySlider_Interpolate.Value;
                                    myWindow1.myLabel_ChangeCount.Content = myInt_ChangeCount++.ToString();
                                    using (Transaction y = new Transaction(doc, "a Transform"))
                                    {
                                        y.Start();

                                        myReferencePoint_Departure.SetCoordinateSystem(myWindow1.myListTransform_Interpolate[(int)myDouble_ChangePosition]);

                                        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_Interpolate.Value.ToString();

                            if (myIntTimeOut == 400)
                            {
                                MessageBox.Show("Timeout");
                                break;
                            }
                        }
                    }

                    transGroup.Assimilate();
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE01_Part1_Interpolate" + 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
        }