コード例 #1
0
        /// <summary>
        /// need OPEN TRANSACTION
        /// </summary>
        public override void Execute()
        {
            var doc = this.fs.Document;

            if (this.hostFace != null &&
                this.hostFace.Reference != null)
            {
                this.referenceString = this.hostFace.Reference.ConvertToStableRepresentation(doc);
            }
            //project offset line onto host face
            if (this.hostFaceRef == null && this.hostFace == null)
            {
                ThrowHostNotFound();
            }
            var locLine = getLocLine();

            if (this.hostFaceRef != null)
            {
                base.Elem = doc.Create.NewFamilyInstance(this.hostFaceRef, locLine, this.fs);
            }
            else if (this.referenceString != null)
            {
                var hostFaceRef = Reference.ParseFromStableRepresentation(doc, this.referenceString);
                base.Elem = doc.Create.NewFamilyInstance(hostFaceRef, locLine, this.fs);
            }
            else if (this.hostFace != null)
            {
                try
                {
                    base.Elem = doc.Create.NewFamilyInstance(this.hostFace, locLine, this.fs);
                }
                catch (Autodesk.Revit.Exceptions.ArgumentsInconsistentException ex)
                {
                    FamilyCreator.HostsWithInstanceFaceProblem.Add(this.Host);
                }
                catch (Autodesk.Revit.Exceptions.InvalidOperationException ex)
                {
                    FamilyCreator.HostsWithInstanceFaceProblem.Add(this.Host);
                }
            }

            if (this.NewFI == null)
            {
                return;
            }
            FamilyEditor.SetParams(this.NewFI, this.paramValues);
            //offset from host
            calcOffset();
        }
コード例 #2
0
        public override void Execute()
        {
            var doc = this.fs.Document;

            if (this.hostWall != null)
            {
                var level = doc.GetElement(this.hostWall.LevelId) as Level;
                base.Elem = doc.Create.NewFamilyInstance(this.pos, this.fs, this.hostWall, level, this.sType);
                FamilyEditor.SetParams(this.NewFI, this.paramValues);
            }
            else
            {
                ThrowHostNotFound();
            }
        }
コード例 #3
0
        /// <summary>
        /// need OPEN TRANSACTION
        /// </summary>
        public override void Execute()
        {
            var doc = this.fs.Document;

            if (this.sType != StructuralType.Footing)
            {
                //create new on level
                var locLine = getLocLine();
                base.Elem = doc.Create.NewFamilyInstance(locLine, this.fs, this.hostLevel, this.sType);
            }
            else
            {
                //find face on temp geom
                PlanarFace pf = this.tempDS.GetAllSolids()
                                .SelectMany(s => s.Faces.Cast <PlanarFace>())
                                .Where(f => f != null)
                                .FirstOrDefault(f => f.FaceNormal.IsAlmostEqualToByDifference(XYZ.BasisZ, 0.0001));

                var tempFi = doc.Create.NewFamilyInstance(pf, this.offsetLocLine, fs);
                //copy to level
                var cpo       = new CopyPasteOptions();
                var newCopies = ElementTransformUtils.CopyElements
                                    (this.viewPlan,
                                    new ElementId[1] {
                    tempFi.Id
                },
                                    this.viewPlan, null, cpo);
                base.Elem = doc.GetElement(newCopies.First()) as FamilyInstance;
                //delete temp elems
                doc.Delete(tempFi.Id);
                if (this.tempDS != null)
                {
                    doc.Delete(this.tempDS.Id);
                }
            }

            if (this.NewFI == null)
            {
                return;
            }
            FamilyEditor.SetParams(this.NewFI, this.paramValues);

            calcOffset();
        }
コード例 #4
0
        /// <summary>
        /// need OPEN TRANSACTION
        /// </summary>
        public override void Execute()
        {
            var doc = this.fs.Document;

            if (this.HostFaceRef != null)
            {
                base.Elem = doc.Create.NewFamilyInstance(this.HostFaceRef, this.Pos, this.Hand, this.fs);
            }
            else if (this.HostFace != null)
            {
                base.Elem = doc.Create.NewFamilyInstance(this.HostFace, this.Pos, this.Hand, this.fs);
            }
            else
            {
                ThrowHostNotFound();
            }
            if (this.flipFacing)
            {
                this.NewFI.flipFacing();
            }
            FamilyEditor.SetParams(NewFI, this.paramValues);
        }