public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; doc = uidoc.Document; Selection sel = uidoc.Selection; Reference rf = sel.PickObject(ObjectType.Element); ElementtransformToCopy kl = new ElementtransformToCopy(); Element ele = doc.GetElement(rf); FamilyInstance familyInstance = ele as FamilyInstance; FamilyInstance flat = kl.GetFlat(doc, familyInstance); var t1 = flat.GetReferences(FamilyInstanceReferenceType.StrongReference).First(); var t2 = flat.GetReferences(FamilyInstanceReferenceType.StrongReference).First(); Transform transform = flat.GetTransform(); EdgeArray edgeArray = kl.FlEdgeArray(flat); List <Edge> list = new List <Edge>(); foreach (Edge i in edgeArray) { list.Add(i); } list.OrderBy(i => i.ApproximateLength).ToList(); Edge max = list.Last(); Curve cure = max.AsCurve(); Line lop = cure as Line; ReferenceArray referenceArray = new ReferenceArray(); XYZ startpoint = lop.GetEndPoint(0); XYZ endpoint = lop.GetEndPoint(1); using (Transaction tr = new Transaction(doc, "cre")) { tr.Start(); Line line = Line.CreateBound(transform.OfPoint(startpoint), transform.OfPoint(endpoint)); DetailLine detailLine = doc.Create.NewDetailCurve(doc.ActiveView, line) as DetailLine; referenceArray.Append(t1); referenceArray.Append(t2); var t = doc.Create.NewDimension(doc.ActiveView, line, referenceArray); tr.Commit(); } return(Result.Succeeded); }
public bool CheckInAssembly(Document doc, FamilyInstance familyInstance) { bool flag = false; ElementtransformToCopy elementtransformToCopy = new ElementtransformToCopy(); FamilyInstance source = elementtransformToCopy.GetFlat(doc, familyInstance); if (source != null) { if (source.AssemblyInstanceId.IntegerValue != -1) { flag = true; } } else { if (familyInstance.AssemblyInstanceId.IntegerValue != -1) { flag = true; } } return(flag); }
public void Caculator(FamilyInstance familyInstance) { ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, familyInstance); if (flat != null) { Parameter volume = flat.LookupParameter("Volume"); double Value = volume.AsDouble(); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; PRODWT_TKT_WEIGHT = k2.ToString(); } else { Parameter volume = familyInstance.LookupParameter("Volume"); double Value = volume.AsDouble(); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; PRODWT_TKT_WEIGHT = k2.ToString(); } Parameter pa = familyInstance.LookupParameter("ENGDSN"); if (pa != null) { DESIGNSHT_ENGDSN = pa.AsString(); } else { DESIGNSHT_ENGDSN = ""; } Parameter pa2 = familyInstance.LookupParameter("HDLDSN"); if (pa2 != null) { HANDLINGSHT_HDLDSN = pa2.AsString(); } else { HANDLINGSHT_HDLDSN = ""; } Parameter pa3 = familyInstance.LookupParameter("PRDTCODE"); if (pa3 != null) { PRODTYPE_PRDTCODE = pa3.AsString(); } else { PRODTYPE_PRDTCODE = ""; } switch (DESIGNSHT_ENGDSN) { case "2.1.0": RELEASESTR_STRIPPING_STRENGTH = "4000"; DAYSTR_28_DAY_STRENGTH = "6500"; break; case "2.2.0": RELEASESTR_STRIPPING_STRENGTH = "4000"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "2.3.0": RELEASESTR_STRIPPING_STRENGTH = "4000"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "3.1.0": RELEASESTR_STRIPPING_STRENGTH = "4000"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "3.2.0": RELEASESTR_STRIPPING_STRENGTH = "4000"; DAYSTR_28_DAY_STRENGTH = "7500"; break; case "4.1.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "4.2.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "7500"; break; case "4.3.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "4.4.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "4.5.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "5.1.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "5.2.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "5.3.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "7000"; break; case "5.4.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "5.6.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "6.1.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "6.2.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "7.1.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "7.2.0": RELEASESTR_STRIPPING_STRENGTH = "2500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; case "7.3.0": RELEASESTR_STRIPPING_STRENGTH = "3500"; DAYSTR_28_DAY_STRENGTH = "6000"; break; default: break; } BACKUPC_TKT_CUYDS = Math.Round(Convert.ToDouble(PRODWT_TKT_WEIGHT) / (150 * 27), 2).ToString(); }
public void CopyElementsFlatToWarped(Document doc, FamilyInstance familyInstance, ICollection <ElementId> elementIds, Selection sel) { ICollection <ElementId> newlist = new List <ElementId>(); CopyPasteOptions option = new CopyPasteOptions(); ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, familyInstance); List <PlanarFace> list1 = FlFaces(flat); FamilyInstance warped = tr.GetWarped(doc, familyInstance); PlanarFace face1 = Facemax(list1); Element element1 = doc.GetElement(elementIds.First()); LocationPoint loc = element1.Location as LocationPoint; XYZ pointorg = loc.Point; //double minspace = MinSpacePlanarFace(doc, familyInstance, face1, pointorg); Transform transform = TransformFlatWapred(doc, flat, warped); //Solid solid1 = Solidhelper.AllSolids(flat).First(); //Solid solid2 = Solidhelper.AllSolids(warped).First(); //Transform transform1 = solid1.GetBoundingBox().Transform; //Transform transform2 = solid2.GetBoundingBox().Transform; //Transform transform = transform1.Inverse.Multiply(transform2); using (Transaction tran = new Transaction(doc, "copy")) { tran.Start(); FailureHandlingOptions options = tran.GetFailureHandlingOptions(); IgnoreProcess ignoreProcess = new IgnoreProcess(); options.SetClearAfterRollback(true); options.SetFailuresPreprocessor(ignoreProcess); tran.SetFailureHandlingOptions(options); try { newlist = ElementTransformUtils.CopyElements(doc, elementIds, doc, transform, option); Remove_product(doc, newlist); } catch (Exception) { } foreach (ElementId eleid in newlist) { Element ele = doc.GetElement(eleid); LocationPoint locele = ele.Location as LocationPoint; XYZ pointcon = locele.Point; List <HermiteFace> list2 = WarpedFace(warped); if (list2.Count != 0) { HermiteFace face2 = FacemaxWraped(list2); //double distanceloc = kcpointtoHemiteFace(face2, pointcon); double distanceloc = MinSpaceHermiteFace(doc, familyInstance, face2, pointcon); var xv1 = FIndpointonwraped(pointcon, new XYZ(0, 0, 1), distanceloc); XYZ point1 = pointcon - xv1; ElementTransformUtils.MoveElement(doc, eleid, point1); } else { List <RevolvedFace> revolvedFaces = WarpedFaceRevolFace(warped); RevolvedFace face2 = FacemaxWrapedRevolFace(revolvedFaces); //double distanceloc = kcpointtoHemiteFace(face2, pointcon); double distanceloc = MinSpaceRevolFace(doc, familyInstance, face2, pointcon); var xv1 = FIndpointonwraped(pointcon, new XYZ(0, 0, 1), distanceloc); XYZ point1 = pointcon - xv1; ElementTransformUtils.MoveElement(doc, eleid, point1); } //if (minspace > 0) //{ // var xv1 = FIndpointonwraped(pointcon,doc.ActiveView.UpDirection, distanceloc); // XYZ point1 = pointcon - xv1; // ElementTransformUtils.MoveElement(doc, eleid, point1); //} //else //{ // var xv1 = FIndpointonwraped(pointcon, doc.ActiveView.UpDirection, distanceloc); // XYZ point1 = xv1 - pointcon; // ElementTransformUtils.MoveElement(doc, eleid, point1); //} } tran.Commit(); } }
public void Setvalue(Document doc, List <FamilyInstance> list, string value) { ProgressbarWPF progressBarform = new ProgressbarWPF(list.Count, "Loading..."); progressBarform.Show(); var ListCorbelHaunch = FindAllLedgeHaunches(doc); foreach (var i in list) { progressBarform.Giatri(); if (progressBarform.iscontinue == false) { break; } if (!CheckInAssembly(doc, i)) { var listintersect = FindledgeandhaunchesNearly(doc, i, ListCorbelHaunch); Parameter commentdata = i.LookupParameter(value); string hj = commentdata.AsString(); using (Transaction tran = new Transaction(doc, "Set")) { tran.Start(); ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, i); FamilyInstance wapred = tr.GetWarped(doc, i); if (flat != null) { Parameter FlatVolumnTag = flat.LookupParameter(value); Parameter WarpedVolumnTag = wapred.LookupParameter(value); Parameter volume = flat.LookupParameter("Volume"); double Value = volume.AsDouble() + VolumnCorbelHaunch(listintersect); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; commentdata.Set(k2.ToString()); FlatVolumnTag.Set(k2.ToString()); WarpedVolumnTag.Set(k2.ToString()); string gh = commentdata.AsString(); } else { Parameter volume = i.LookupParameter("Volume"); double Value = volume.AsDouble() + VolumnCorbelHaunch(listintersect); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; commentdata.Set(k2.ToString()); string gh = commentdata.AsString(); } tran.Commit(); } } else { using (Transaction tran = new Transaction(doc, "Set")) { tran.Start(); Parameter commentdata = i.LookupParameter(value); if (!string.IsNullOrEmpty(commentdata.AsString())) { ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, i); FamilyInstance wapred = tr.GetWarped(doc, i); Parameter paproduct = i.LookupParameter(value); string CVl = paproduct.AsString(); if (flat != null) { Parameter FlatVolumnTag = flat.LookupParameter(value); Parameter WarpedVolumnTag = wapred.LookupParameter(value); FlatVolumnTag.Set(CVl); WarpedVolumnTag.Set(CVl); } } else { var listintersect = FindledgeandhaunchesNearly(doc, i, ListCorbelHaunch); ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, i); FamilyInstance wapred = tr.GetWarped(doc, i); if (flat != null) { Parameter FlatVolumnTag = flat.LookupParameter(value); Parameter WarpedVolumnTag = wapred.LookupParameter(value); Parameter volume = flat.LookupParameter("Volume"); double Value = volume.AsDouble() + VolumnCorbelHaunch(listintersect); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; commentdata.Set(k2.ToString()); FlatVolumnTag.Set(k2.ToString()); WarpedVolumnTag.Set(k2.ToString()); string gh = commentdata.AsString(); } else { Parameter volume = i.LookupParameter("Volume"); double Value = volume.AsDouble() + VolumnCorbelHaunch(listintersect); double kl = Value * 150; double k1 = Math.Round(kl / 1000, 1); double k2 = k1 * 1000; commentdata.Set(k2.ToString()); string gh = commentdata.AsString(); } } tran.Commit(); } } } progressBarform.Close(); }