/// <summary> /// Export all the parts of the host element. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="hostElement">The host element having parts to export.</param> /// <param name="hostHandle">The host element handle.</param> /// <param name="originalWrapper">The ProductWrapper object.</param> public static void ExportHostPart(ExporterIFC exporterIFC, Element hostElement, IFCAnyHandle hostHandle, ProductWrapper originalWrapper, PlacementSetter placementSetter, IFCAnyHandle originalPlacement, ElementId overrideLevelId) { using (ProductWrapper subWrapper = ProductWrapper.Create(exporterIFC, true)) { List <ElementId> associatedPartsList = PartUtils.GetAssociatedParts(hostElement.Document, hostElement.Id, false, true).ToList(); if (associatedPartsList.Count == 0) { return; } bool isWallOrColumn = IsHostWallOrColumn(exporterIFC, hostElement); bool hasOverrideLevel = overrideLevelId != null && overrideLevelId != ElementId.InvalidElementId; IFCExtrusionAxes ifcExtrusionAxes = GetDefaultExtrusionAxesForHost(exporterIFC, hostElement); // Split parts if wall or column is split by level, and then export; otherwise, export parts normally. if (isWallOrColumn && hasOverrideLevel && ExporterCacheManager.ExportOptionsCache.WallAndColumnSplitting) { if (!ExporterCacheManager.HostPartsCache.HasRegistered(hostElement.Id)) { SplitParts(exporterIFC, hostElement, associatedPartsList); // Split parts and associate them with host. } // Find and export the parts that are split by specific level. List <KeyValuePair <Part, IFCRange> > splitPartRangeList = new List <KeyValuePair <Part, IFCRange> >(); splitPartRangeList = ExporterCacheManager.HostPartsCache.Find(hostElement.Id, overrideLevelId); if (splitPartRangeList != null) { foreach (KeyValuePair <Part, IFCRange> partRange in splitPartRangeList) { PartExporter.ExportPart(exporterIFC, partRange.Key, subWrapper, placementSetter, originalPlacement, partRange.Value, ifcExtrusionAxes, hostElement, overrideLevelId, false); } } } else { foreach (ElementId partId in associatedPartsList) { Part part = hostElement.Document.GetElement(partId) as Part; PartExporter.ExportPart(exporterIFC, part, subWrapper, placementSetter, originalPlacement, null, ifcExtrusionAxes, hostElement, overrideLevelId, false); } } // Create the relationship of Host and Parts. ICollection <IFCAnyHandle> relatedElementIds = subWrapper.GetAllObjects(); if (relatedElementIds.Count > 0) { string guid = GUIDUtil.CreateGUID(); HashSet <IFCAnyHandle> relatedElementIdSet = new HashSet <IFCAnyHandle>(relatedElementIds); IFCInstanceExporter.CreateRelAggregates(exporterIFC.GetFile(), guid, ExporterCacheManager.OwnerHistoryHandle, null, null, hostHandle, relatedElementIdSet); } } }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- List <string> newFileName = new List <string>(); if (file.Path == "") { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请指定文件位置"); return(1); } foreach (Node node in treeElectrode.GetSelectedNodes()) { ElectrodeModel model = assemble.Electrodes.Find(a => node.Equals(a.Node)); if (model != null) { ExportFile path = new ExportFile(model); string temp = path.NewFile(file.Path); newFileName.Add(temp); model.PartTag.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null); Part newPart = PartUtils.OpenPartFile(temp); PartUtils.SetPartDisplay(newPart); if (this.toggleShops.Value && IsPartProgram(newPart)) { PartPost elePost = new PartPost(newPart); List <NCGroup> groups = elePost.GetGroup(); CreatePostExcel excel = new CreatePostExcel(groups, newPart); excel.CreateExcel(); string[] name = elePost.GetElectrodePostName(groups); foreach (string str in name) { elePost.Post(str, groups.ToArray()); } } newPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False); } } foreach (Part part in theSession.Parts)//关闭其他 { string type = AttributeUtils.GetAttrForString(part, "PartType"); if (!type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase)) { part.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null); } } } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- NXOpen.Assemblies.Component ct = seleComp.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; Part workPart = theSession.Parts.Work; if (ct != null) { List <string> err = new List <string>(); bool isBorrow; if (this.enum0.ValueAsString == "借用电极") { isBorrow = true; } else { isBorrow = false; } MoldInfo old = MoldInfo.GetAttribute(ct); MoldInfo mold = new MoldInfo() { MoldNumber = this.MoldNumber.WideValue.ToUpper(), WorkpieceNumber = this.PartNumber.WideValue.ToUpper(), ClientName = this.ClientNumber.WideValue.ToUpper(), EditionNumber = this.EditionNumber.WideValue.ToUpper(), MoldType = old.MoldType }; ParentAssmblieInfo info = new ParentAssmblieInfo(mold, user.CreatorUser); WorkCollection wkColl = asmColl.GetWorkCollection(old); err.AddRange(AlterWork(wkColl.Work, info)); err.AddRange(AlterEdm(wkColl.EdmModel, info)); err.AddRange(AlterElectrode(wkColl.Electrodes, info, isBorrow)); PartUtils.SetPartDisplay(workPart); ASMModel asm = new ASMModel(workPart); if (asm.Info.MoldInfo.Equals(old)) { err.AddRange(AlterAsm(asm, info)); } if (err.Count > 0) { ClassItem.Print(err.ToArray()); } } } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
public virtual IPart ParsePart(IMessageReader reader, string contentId, ContentType contentType, ContentDisposition contentDisposition, EContentTransferEncoding contentTransferEncoding, string uid, string attachmentDirectory, string boundary, PopMessage parentMessage) { if (PartUtils.IsMultipart(contentType)) { MultiPartParser parser = new MultiPartParser(); parser.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); return(parser.Parse(reader, contentTransferEncoding, boundary, uid, attachmentDirectory, parentMessage, contentType)); } if (PartUtils.IsTextPart(contentType, contentDisposition)) { string charset = contentType.Attributes.ContainsKey("charset") ? contentType.Attributes["charset"] : "us-ascii"; TextPartParser parser2 = new TextPartParser(charset); parser2.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); return(parser2.Parse(reader, contentType, contentDisposition, contentTransferEncoding, boundary)); } if (PartUtils.IsMessagePart(contentType) && (contentType.SubType == "delivery-status")) { MessageDeliveryStatusPartParser parser3 = new MessageDeliveryStatusPartParser(); parser3.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); return(parser3.Parse(reader, contentType, contentDisposition, contentTransferEncoding, boundary)); } if (PartUtils.IsMessagePart(contentType) && (contentType.SubType == "disposition-notification")) { MessageDispositionNotificationPartParser parser4 = new MessageDispositionNotificationPartParser(); parser4.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); return(parser4.Parse(reader, contentType, contentDisposition, contentTransferEncoding, boundary)); } if (PartUtils.IsMessagePart(contentType)) { MessagePartParser parser5 = new MessagePartParser(); parser5.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); return(parser5.Parse(reader, contentType, contentDisposition, contentTransferEncoding, boundary, uid, attachmentDirectory)); } attachmentDirectory = Path.Combine(attachmentDirectory, MailClient.MessageFolderPrefix + IOUtil.FormatFileSystemName(uid)); ContentPartParser parser6 = new ContentPartParser(attachmentDirectory); parser6.FinalBoundaryReached += new EventHandler(this.childParser_FinalBoundaryReached); ContentPart part2 = (ContentPart)parser6.Parse(reader, contentType, contentDisposition, contentTransferEncoding, boundary); IPart part = part2; Attachment attachment = new Attachment(part2.DiskFilename, contentId, contentType, attachmentDirectory, part2.Size) { DiskFilename = part2.DiskFilename, TransferFilename = part2.TransferFilename, AttachmentDirectory = attachmentDirectory, ContentID = contentId, ContentType = contentType }; if (!attachment.TransferFilenameExtension.Equals(".octet-stream", StringComparison.OrdinalIgnoreCase)) { parentMessage.Attachments.Add(attachment); } return(part); }
/// <summary> /// 修改版本 /// </summary> /// <param name="editionNumber"></param> private void UpdateEditionNumber(string editionNumber) { UFSession theUFSession = UFSession.GetUFSession(); Session theSession = Session.GetSession(); MoldInfo mf = asm.Info.MoldInfo; mf.EditionNumber = editionNumber; mf.SetAttribute(asm.PartTag); foreach (ElectrodeModel em in asmColl.GetElectrodes()) { MoldInfo mi = em.Info.MoldInfo; mi.EditionNumber = editionNumber; mi.SetAttribute(em.PartTag); string dwgName = em.Info.AllInfo.Name.EleName + "_dwg"; string dwg = em.WorkpieceDirectoryPath + em.Info.AllInfo.Name.EleName + "_dwg.prt"; if (File.Exists(dwg)) { Part dwgPart = null; try { dwgPart = theSession.Parts.FindObject(dwgName) as Part; if (dwgPart != null) { mi.SetAttribute(dwgPart); continue; } } catch { } Tag part; UFPart.LoadStatus error_status; theUFSession.Part.Open(dwg, out part, out error_status); mi.SetAttribute(NXObjectManager.Get(part) as Part); } } foreach (MoldInfo mi in asmColl.MoldInfo) { WorkCollection wkColl = asmColl.GetWorkCollection(mi); foreach (WorkModel wm in wkColl.Work) { MoldInfo wmMold = wm.Info.MoldInfo; wmMold.EditionNumber = editionNumber; wmMold.SetAttribute(wm.PartTag); } foreach (EDMModel em in wkColl.EdmModel) { MoldInfo wmMold = em.Info.MoldInfo; wmMold.EditionNumber = editionNumber; wmMold.SetAttribute(em.PartTag); } } PartUtils.SetPartDisplay(asm.PartTag); }
public override void CreatePart() { if (File.Exists(this.WorkpiecePath)) { File.Delete(this.WorkpiecePath); } Part part = PartUtils.NewFile(this.WorkpiecePath) as Part; this.PartTag = part; SetAttribute(); }
/// <summary> /// 创建part档 /// </summary> /// <returns></returns> private NXOpen.Assemblies.Component CreateElePart() { NXOpen.Assemblies.Component eleComp = elePart.Create(); if (eleComp != null) { PartUtils.SetPartWork(eleComp); NXOpen.Features.Feature feat = AssmbliesUtils.WaveBodys(this.head.ConditionModel.Bodys.ToArray()); this.waveBodys = (feat as NXOpen.Features.BodyFeature).GetBodies(); } return(eleComp); }
public void Alter() { Part asm = Session.GetSession().Parts.Work; foreach (ElectrodeModel ele in Model) { AlterElectrode(info, ele); } AlterDrawing(); AlterWorkDrawing(); PartUtils.SetPartDisplay(asm); }
public bool Create() { IList <ElementId> idList = new List <ElementId>(); ICollection <ElementId> elementIdsToDivide = new List <ElementId>(); idList.Add(Floor.Id); if (PartUtils.AreElementsValidForCreateParts(PublicVariables.Doc, idList)) { using (Transaction tr = new Transaction(PublicVariables.Doc, "CreatePart")) { tr.Start(); try { PartUtils.CreateParts(PublicVariables.Doc, idList); tr.Commit(); } catch { tr.RollBack(); } elementIdsToDivide = PartUtils.GetAssociatedParts(PublicVariables.Doc , Floor.Id, true, true); } } ICollection <ElementId> intersectingReferenceIds = new List <ElementId>(); var curveList = (from Curve elem in BoundingSquare select elem).ToList(); using (Transaction tr = new Transaction(PublicVariables.Doc, "DivideParts")) { tr.Start(); try { SketchPlane sp = SketchPlane.Create(PublicVariables.Doc, Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), BoundingSquare[0].GetEndPoint(0))); PartMaker maker = PartUtils.DivideParts(PublicVariables.Doc, elementIdsToDivide, intersectingReferenceIds, curveList, sp.Id); Parameter partVisInView = PublicVariables.Doc.ActiveView.get_Parameter(BuiltInParameter.VIEW_PARTS_VISIBILITY); partVisInView.Set(0); tr.Commit(); } catch { tr.RollBack(); } } return(true); }
/// <summary> /// 更新work零件明细表 /// </summary> private void AlterWorkDrawing() { Part workPart = Session.GetSession().Parts.Work; UFSession theUFSession = UFSession.GetUFSession(); if (!workPart.Equals(work.PartTag)) { NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, work.PartTag); PartUtils.SetPartWork(ct); } theUFSession.Plist.UpdateAllPlists(); PartUtils.SetPartWork(null); }
public bool CheckPrereq(ICurrentEventInfo info) { if (!attr.Scenes.IsLoaded()) { return(false); } // ReSharper disable once InvokeAsExtensionMethod SourcePart can be null if (!PartUtils.RelationTest(info.SourcePart, TargetPart, attr.Relations)) { return(false); } return(true); }
public AbstractElectrodeOperation(ElectrodeModel ele, bool isInter) { this.ele = ele; Part workPart = Session.GetSession().Parts.Work; camInfo = new ElectrodeCAMInfo(ele, isInter); tool = new ComputeTool(camInfo.MinDim, camInfo.MinDia); if (workPart.Tag != ele.PartTag.Tag) { PartUtils.SetPartDisplay(ele.PartTag); } Cam = new ElectrodeCAM(); }
/// <summary> /// 画中心点和中心线 /// </summary> /// <param name="disPt"></param> public void CreatePointAndCenterLine(Point3d centerPt, Point3d disPt) { Part workPart = Session.GetSession().Parts.Work; if (workPart.Tag != PartTag.Tag) { NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, PartTag); PartUtils.SetPartWork(ct); } CreateCenterLine(centerPt, disPt); CreateCenterPoint(); PartUtils.SetPartWork(null); }
/// <summary> /// 更新图纸 /// </summary> public void UpdateDrawing() { string dwgName = eleModel.Info.AllInfo.Name.EleName + "_dwg"; string path = eleModel.WorkpieceDirectoryPath + dwgName + ".prt"; if (!File.Exists(path)) { return; } Part dwg = null; foreach (Part part in Session.GetSession().Parts) { if (part.Name.ToUpper().Equals(dwgName.ToUpper())) { dwg = part; break; } } if (dwg == null) { if (File.Exists(path)) { dwg = PartUtils.OpenPartFile(path); } } if (dwg != null) { newAllInfo.SetAttribute(dwg); string temp = newAllInfo.Preparetion.Preparation[0].ToString() + "*" + newAllInfo.Preparetion.Preparation[1].ToString() + "*" + newAllInfo.Preparetion.Preparation[2].ToString(); AttributeUtils.AttributeOperation("StrPre", temp, dwg); if (!oldAllInfo.Pitch.IsEquals(newAllInfo.Pitch)) { PartUtils.SetPartDisplay(dwg); LayerUtils.MoveDisplayableObject(201, GetDrawingBody(dwg).ToArray()); foreach (NXOpen.Drawings.DrawingSheet sh in dwg.DrawingSheets) { Basic.DrawingUtils.UpdateViews(sh); } } if (!oldAllInfo.Preparetion.IsEquals(newAllInfo.Preparetion)) { foreach (NXOpen.Drawings.DrawingSheet sh in dwg.DrawingSheets) { Basic.DrawingUtils.UpdateViews(sh); } } newAllInfo.SetAttribute(dwg); PartUtils.SetPartDisplay(asm); } }
/// <summary> /// 更新Pitch /// </summary> private bool UpdatePitch() { Part workPart = Session.GetSession().Parts.Work; NXOpen.Features.ExtractFace ext; NXOpen.Features.MoveObject move; NXOpen.Features.PatternGeometry patt; List <Body> bodys = new List <Body>(); Body boolBody; List <NXOpen.Features.BooleanFeature> extBools; GetExtrudeBooleanBody(out boolBody, out extBools); GetFeature(out ext, out move, out patt); if (ext == null || move == null || patt == null || boolBody == null) { return(false); } if (extBools.Count > 0) { DeleteObject.Delete(extBools.ToArray()); } bodys.AddRange(ext.GetBodies()); bodys.AddRange(patt.GetAssociatedBodies()); try { MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", move as NXOpen.Features.MoveObject, bodys.ToArray()); } catch (NXException ex) { ClassItem.WriteLogFile("更新移动错误!" + ex.Message); return(false); } List <Body> bys = eleModel.PartTag.Bodies.ToArray().ToList(); bys.Remove(boolBody); SetHeadColour(newAllInfo.Pitch, newAllInfo.GapValue, bys); try { PartUtils.SetPartWork(AssmbliesUtils.GetPartComp(asm, eleModel.PartTag)[0]); Body elebody = BooleanUtils.CreateBooleanFeature(boolBody, false, false, NXOpen.Features.Feature.BooleanType.Unite, bys.ToArray()).GetBodies()[0]; SetEleColor(elebody); PartUtils.SetPartWork(null); } catch (NXException ex) { ClassItem.WriteLogFile("更新求和错误!" + ex.Message); return(false); } return(true); }
public static void CreateBuilder(MoldInfoModel moldInfo) { Part workPart = Session.GetSession().Parts.Work; NXOpen.Assemblies.Component ct = workPart.ComponentAssembly.RootComponent; if (ct != null) { UI.GetUI().NXMessageBox.Show("错误!", NXMessageBox.DialogType.Error, "工件是装配关系"); return; } CsysUtils.SetWcsToAbs(); Matrix4 mat = new Matrix4(); mat.Identity(); string name = moldInfo.MoldNumber + "-" + moldInfo.WorkpieceNumber + moldInfo.EditionNumber; string partfull = workPart.FullPath; string path; if (workPart.Name.Equals(name)) { path = Path.GetDirectoryName(partfull) + "\\"; } else { path = Path.GetDirectoryName(partfull) + "\\" + moldInfo.WorkpieceNumber + "-" + moldInfo.EditionNumber + "\\"; } CreateAsmPart asm = new CreateAsmPart(path, moldInfo); CreateEdmPart edm = new CreateEdmPart(path, moldInfo); CreateWorkPart work = new CreateWorkPart(path, moldInfo, 1, mat); CreateWorkpiecePart workpiece = new CreateWorkpiecePart(path, workPart, moldInfo); workpiece.CreatePart(); asm.CreatePart(); edm.CreatePart(); work.CreatePart(); workpiece.Load(edm.Model.PartTag); edm.Load(work.Model.PartTag); work.Load(asm.Model.PartTag); work.Model.WaveBodys(); PartUtils.SetPartDisplay(asm.Model.PartTag); bool anyPartsModified1; NXOpen.PartSaveStatus partSaveStatus1; Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1); }
private void buttOk_Click(object sender, EventArgs e) { WorkForWorkpieceDrawing dra; for (int i = 0; i < listView.Items.Count; i++) { if (listView.Items[i].Checked) { string workNum = listView.Items[i].SubItems[2].Text.ToString(); dra = new WorkForWorkpieceDrawing(this.assemble, int.Parse(workNum)); dra.CreateDrawing(); } } PartUtils.SetPartDisplay(this.assemble.Asm.PartTag); this.Close(); }
/// <summary> /// 创建图纸part /// </summary> private void CreatDwgPart() { foreach (Part part in Session.GetSession().Parts) { if (part.Name.ToUpper().Equals(model.AssembleName.ToUpper())) { part.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null); } } model.CreatePart(asm.WorkpieceDirectoryPath); model.LoadWork(); PartUtils.SetPartDisplay(model.PartTag); model.PartTag.Layers.SetState(201, NXOpen.Layer.State.Selectable); model.GetBoundingBox(out centerPt, out disPt); model.GetHidden(out setValueHidden, out eleHidden); }
private void buttOk_Click(object sender, EventArgs e) { ElectrodeDrawing dra; for (int i = 0; i < listView.Items.Count; i++) { if (listView.Items[i].Checked) { string eleName = listView.Items[i].SubItems[2].Text.ToString(); dra = new ElectrodeDrawing(this.assemble, eleName); dra.CreateDrawing(); } } PartUtils.SetPartDisplay(this.assemble.Asm.PartTag); Session.GetSession().ApplicationSwitchImmediate("UG_APP_MODELING"); this.Close(); }
public override List <string> CreatePart(string directoryPath) { List <string> err = new List <string>(); foreach (AbstractAssmbileModel am in models) { if (!am.CreatePart(directoryPath)) { err.Add(am.AssembleName + "创建失败"); } } if (asmModel.PartTag != null) { PartUtils.SetPartDisplay(asmModel.PartTag); } return(err); }
public bool CreateElectrode(bool zDatum, double zHeight, Action exp) { NXOpen.Assemblies.Component eleComp = this.CreateElePart(); if (eleComp != null) { exp.Invoke(); this.CreateBodyFeature(zHeight); this.CreateSeat(zHeight, zDatum); CreateCenterPoint(); PartUtils.SetPartWork(null); Vector3d vec = GetMove(); AssmbliesUtils.MoveCompPart(eleComp, vec, head.ConditionModel.Work.WorkMatr); //移动装配 MoveObjectLayer(100 + eleInfo.EleNumber, this.head.ConditionModel.Bodys.ToArray()); return(true); } return(false); }
/// <summary> /// 修改矩阵 /// </summary> /// <param name="mat"></param> /// <param name="workNumber"></param> /// <returns></returns> public bool AlterMatr(Matrix4 mat, int workNumber) { WorkModel work = this.Model.Works.Find(x => x.WorkNumber == workNumber); if (work != null) { NXOpen.Assemblies.Component workComp = work.PartTag.OwningComponent.Parent; PartUtils.SetPartWork(workComp); work.AlterMatr(mat); CartesianCoordinateSystem csys = work.PartTag.WCS.Save(); csys.Name = "WORK" + workNumber.ToString(); csys.Color = 186; csys.Layer = 200; return(true); } return(false); }
/// <summary> ///连接电极 /// </summary> /// <param name="headBodys"></param> /// <returns></returns> public List <Body> WaveEleHeadBody(List <Body> headBodys) { try { PartUtils.SetPartWork(this.EleComp); List <Body> waveBodys = AssmbliesUtils.WaveBodys(headBodys.ToArray()).GetBodies().ToList(); Matrix4 inv = this.info.Matr.GetInversMatrix(); CoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(this.info.Matr, inv); NXObject obj = MoveObject.MoveObjectOfCsys(csys, waveBodys.ToArray()); return(waveBodys);; } catch (NXException ex) { ClassItem.WriteLogFile("连接体错误!"); throw ex; } }
private void CreatDwgPart() { foreach (Part part in Session.GetSession().Parts) { if (part.Name.ToUpper().Equals(draInfo.DraModel.AssembleName.ToUpper())) { part.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null); } } if (File.Exists(draInfo.DraModel.WorkpiecePath)) { File.Delete(draInfo.DraModel.WorkpiecePath); } draInfo.DraModel.CreatePart(); draInfo.DraModel.Load(this.draInfo.DraModel.PartTag); PartUtils.SetPartDisplay(draInfo.DraModel.PartTag); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- Part workPart = theSession.Parts.Work; CoordinateSystem wcs = workPart.WCS.CoordinateSystem; Matrix4 matr = new Matrix4(); matr.Identity(); matr.TransformToCsys(wcs, ref matr); string number = this.workNumber.ValueAsString.Substring(4); if (addOrModify.Value) { AddWorkBuilder.CreateWork(matr, Convert.ToInt32(number), asmPart); } else { AddWorkBuilder.AlterMatr(matr, Convert.ToInt32(number), asmPart); } CartesianCoordinateSystem csys = workPart.WCS.Save(); csys.Name = this.workNumber.ValueAsString; csys.Layer = 200; csys.Color = 186; PartUtils.SetPartDisplay(asmPart); CsysUtils.SetWcsToAbs(); DeleteObject.Delete(this.points.ToArray()); bool anyPartsModified1; NXOpen.PartSaveStatus partSaveStatus1; Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1); } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
/// <summary> /// 创建加工操作 /// </summary> public void CreateOperation(bool isInter) { Part workPart = Session.GetSession().Parts.Work; if (workPart.Tag != this.EleModel.PartTag.Tag) { PartUtils.SetPartDisplay(this.EleModel.PartTag); } this.CreateCamSetup(); this.SetWorkpiece(); DeleteObject.UpdateObject(); double inter = GetInter(isInter); foreach (AbstractCreateOperation ao in Oper) { ao.CreateOperation(Cam, inter); } }
public bool ProcessMessage(ArmorEventArgs message) { if (message == null) { return(false); } Part part = PartUtils.GetPart(message.VesselId, message.PartFlightId, message.PartCraftId); if (part == null) { return(false); } Dependencies.Get <IDamageService>().ReduceArmor(part, message.ArmorMassToReduce); return(true); }
public bool ProcessMessage(ForceEventArgs message) { if (message == null) { return(false); } Part part = PartUtils.GetPart(message.VesselId, message.PartFlightId, message.PartCraftId); if (part == null) { return(false); } part.AddForceToPart(new Vector3(message.ForceX, message.ForceY, message.ForceZ), new Vector3(message.PositionX, message.PositionY, message.PositionZ), message.Mode, false); return(true); }
/// <summary> /// 创建part档 /// </summary> /// <param name="directoryPath">文件夹地址加\\</param> /// <returns></returns> public virtual bool CreatePart(string directoryPath) { this.WorkpieceDirectoryPath = directoryPath; this.WorkpiecePath = directoryPath + this.AssembleName + ".prt"; if (File.Exists(this.WorkpiecePath)) { File.Delete(this.WorkpiecePath); } try { Part part = PartUtils.NewFile(this.WorkpiecePath) as Part; this.PartTag = part; SetAttribute(part); return(true); } catch (NXException ex) { ClassItem.WriteLogFile("创建" + this.AssembleName + "失败" + ex.Message); return(false); } }
/// <summary> /// 创建操作 /// </summary> public void CreateOper() { PartUtils.SetPartDisplay(this.EleModel.PartTag); Session theSession = Session.GetSession(); try { if (this.EleModel.PartTag.CAMSetup != null) { return; } } catch { Dictionary <string, double> inters = GetEleInter(); bool isok = OffsetInter(inters); this.EleOper.CreateOperation(isok); theSession.ApplicationSwitchImmediate("UG_APP_MANUFACTURING"); EleModel.PartTag.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False); } }