public void Cmd_DimAlign() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; _ = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Dimension, false, null, "\nSelect dimensions to align: "); if (objIds.Length <= 0) { return; } var pId = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Dimension, true, null, "\nSelect baseline dimension: "); if (pId.Length <= 0) { return; } var pDim = SelectionSet.FromObjectIds(pId); var dims = SelectionSet.FromObjectIds(objIds); acCurEd.Command("_.Dimspace", pDim, dims, string.Empty, 0); }
public void Cmd_DimPrec() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Dimension, false); if (objIds.Length <= 0) { return; } var prec = acCurEd.GetLimitedInteger("Enter new precision: [0-8] ", 0, 8); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var obj in objIds) { var acDim = acTrans.GetObject(obj, OpenMode.ForWrite) as Dimension; if (acDim != null) { acDim.Dimdec = prec; } } acTrans.Commit(); } }
public void Cmd_AutoLayer() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; _ = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var enable = acCurEd.GetBool("\nSet AutoLayer variable: ", "On", "Off"); if (enable != null) { return; } try { SettingsUser.AutoLayerEnabled = enable.Value; } catch (Exception e) { Console.WriteLine(e); MailAgent.Report(e.Message); } }
public static void ListComProps() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurEd = acCurDoc.Editor; var peo = new PromptEntityOptions("\nSelect object: "); var res = acCurEd.GetEntity(peo); if (res.Status != PromptStatus.OK) { return; } using (Transaction acTrans = acCurDoc.TransactionManager.StartOpenCloseTransaction()) { var acEnt = (Entity)acTrans.GetObject(res.ObjectId, OpenMode.ForRead); var acadObj = acEnt.AcadObject; var props = TypeDescriptor.GetProperties(acadObj); foreach (PropertyDescriptor prop in props) { var value = prop.GetValue(acadObj); if (value != null) { acCurEd.WriteMessage("\n{0} = {1}", prop.DisplayName, value.ToString()); } } acTrans.Commit(); } }
public void Cmd_RcDrill() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var filterArgs = new[] { DxfNameEnum.Insert, DxfNameEnum._3Dsolid }; var userSel = acCurEd.GetFilteredSelection(filterArgs, false); if (userSel.Length <= 0) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { CutDrills(userSel, acCurDb, acTrans); acTrans.Commit(); } }
public void Cmd_PartLeader() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; try { Entity jigEnt = MLeaderJigger.Jig(); if (jigEnt != null) { using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var btr = (BlockTableRecord)acTrans.GetObject(acCurDb.CurrentSpaceId, OpenMode.ForWrite); btr.AppendEntity(jigEnt); acTrans.AddNewlyCreatedDBObject(jigEnt, true); var mL = jigEnt as MLeader; if (mL != null) { RcLeader.UpdateLeader(mL, acCurDoc, acCurEd, acTrans); } acTrans.Commit(); } } } catch (Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } }
public void Cmd_Converge() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, false, null, "\nSelect solids to find the convergence of: "); if (objIds.Length <= 1) { return; } var delSols = acCurEd.GetBool("\nDelete consumed solids after performing operation? "); if (delSols == null) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { objIds.SolidConverge(acCurDb, acTrans, delSols.Value); acTrans.Commit(); } }
public static void NumberPages() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var dbDict = (DBDictionary)acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead); var dCount = dbDict.Count - 1; foreach (var curEntry in dbDict) { var layout = (Layout)acTrans.GetObject(curEntry.Value, OpenMode.ForRead); if (layout.LayoutName == "Model") { continue; } using ( var blkTblRec = acTrans.GetObject(layout.BlockTableRecordId, OpenMode.ForRead) as BlockTableRecord) { if (blkTblRec == null) { continue; } foreach (var objId in blkTblRec) { var bRef = acTrans.GetObject(objId, OpenMode.ForRead) as BlockReference; if (bRef == null) { continue; } var curOrder = layout.TabOrder; bRef.UpdateAttributeByTag(SettingsUser.PageNoOf, curOrder.ToString(), acCurDoc, acCurEd, acTrans); bRef.UpdateAttributeByTag(SettingsUser.PageNoTotal, dCount.ToString(), acCurDoc, acCurEd, acTrans); } } } acCurEd.Regen(); acTrans.Commit(); } }
public void Cmd_DimSelect() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; acCurEd.SelectImplied(); var objIds = new List <ObjectId>(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); foreach (var dim in dimSys.SysList) { objIds.Add(dim.ObjectId); } acCurEd.SetImpliedSelection(objIds.ToArray()); } } acTrans.Commit(); } }
public void Cmd_DimBreak() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; _ = acCurDoc.Database; _ = acCurDoc.Editor; }
public void Cmd_SelectUnNamed() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetAllSelection(false); var unNamed = new List <ObjectId>(); using (var pWorker = new ProgressAgent("Finding Unnamed Parts: ", objIds.Length)) { using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var obj in objIds) { if (!pWorker.Progress()) { acTrans.Abort(); return; } var acEnt = acTrans.GetObject(obj, OpenMode.ForRead) as Entity; if (acEnt == null) { continue; } if (string.IsNullOrEmpty(acEnt.GetPartName())) { unNamed.Add(obj); } } if (unNamed.Count > 0) { acCurEd.SetImpliedSelection(unNamed.ToArray()); acCurEd.SelectImplied(); } else { acCurEd.WriteMessage("\nAll selected parts have pre-defined names."); } acTrans.Commit(); } } }
public void Cmd_ShowBounds() { if (!LicensingAgent.Check()) { return; } if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetAllSelection(false); var boolRes = acCurEd.GetBool("Save bounds? "); if (boolRes == null) { return; } var append = boolRes.Value; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var sol = acTrans.GetBoundingBox(objIds, acCurDb); sol.Transparency = new Transparency(75); sol.Color = Colors.LayerColorBounds; TransientAgent.Add(sol); TransientAgent.Draw(); if (append) { acCurDb.AppendEntity(sol); } else { sol.Dispose(); } TransientAgent.Clear(); acTrans.Commit(); } }
public void Cmd_DEBUGBOXES() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; _ = acCurDoc.Editor; var boxCount = 500; var maxSize = 40; var minSize = 5; var minX = -500; var minY = -500; var minZ = -500; var maxX = 500; var maxY = 500; var maxZ = 500; var random = new Random(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { for (var i = 0; i < boxCount; i++) { var acSol = new Solid3d(); var length = random.Next(minSize, maxSize); var width = random.Next(minSize, maxSize); var height = random.Next(minSize, maxSize); acSol.CreateBox(length, width, height); var insertPoint = new Point3d(random.Next(minX, maxX), random.Next(minY, maxY), random.Next(minZ, maxZ)); acCurDb.AppendEntity(acSol); acSol.Move(acSol.GetBoxCenter(), insertPoint); acSol.CleanBody(); } acTrans.Commit(); } }
/// <summary> /// TODO /// </summary> /// <param name="layerName"></param> /// <param name="acColor"></param> private void SetLayer(string layerName, Color acColor) { try { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; if (acCurDoc == null) { return; } var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (acCurDoc.LockDocument()) { Utils.SetFocusToDwgView(); var objIds = acCurEd.GetAllSelection(false); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { acCurDb.AddLayer(layerName, acColor, SettingsUser.RcVisibleLT, acTrans); foreach (var obj in objIds) { var acEnt = acTrans.GetObject(obj, OpenMode.ForWrite) as Entity; if (acEnt == null) { continue; } acEnt.Layer = layerName; acEnt.Color = Color.FromColorIndex(ColorMethod.ByLayer, 256); } acTrans.Commit(); } } } catch (Exception e) { Console.WriteLine(e); MailAgent.Report(e.Message); } }
public void Cmd_EmptyDwg() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var newLayoutName = "BlankLayout"; LayoutManager.Current.CurrentLayout = "Model"; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { try { LayoutManager.Current.CreateLayout(newLayoutName); } catch (Exception e) { Console.WriteLine(e); MailAgent.Report(e.Message); } var layoutDict = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary; if (layoutDict != null) { foreach (var de in layoutDict) { var layoutName = de.Key; if (layoutName != "Model" && layoutName != newLayoutName) { LayoutManager.Current.DeleteLayout(layoutName); } } } acTrans.Commit(); } acCurDb.PurgeAll(true); }
public void Cmd_Scatter() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetAllSelection(false); if (objIds.Length <= 0) { return; } var random = new Random(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var extents = acTrans.GetExtents(objIds, acCurDb); var extCen = Solid3DExtensions.GetBoxCenter(extents.MinPoint, extents.MaxPoint); foreach (var obj in objIds) { var acEnt = acTrans.GetObject(obj, OpenMode.ForWrite) as Entity; if (acEnt == null) { continue; } var entExt = acTrans.GetExtents(new[] { acEnt.ObjectId }, acCurDb); var entCen = Solid3DExtensions.GetBoxCenter(entExt.MinPoint, entExt.MaxPoint); var cPower = extCen.GetVectorTo(entCen).MultiplyBy(random.NextDouble()); acEnt.TransformBy(Matrix3d.Displacement(cPower)); } acTrans.Commit(); } }
public void Cmd_RcUdateChildren() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, true, null, "\nSelect parent object: "); if (objIds.Length <= 0) { return; } UpdateChildren(objIds, acCurEd, acCurDb); }
public void Dump() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; _ = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var entRes = acCurEd.GetEntity("\nSelect object: "); if (entRes.Status == PromptStatus.OK) { PrintDump(entRes.ObjectId, acCurEd); AcAp.DisplayTextScreen = true; } }
public void Cmd_Subtrahend() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds1 = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, false, null, "\nSelect solids to be subtracted from: "); if (objIds1.Length <= 0) { return; } var objIds2 = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, false, null, "\nSelect solids to be used as subtrahends: "); if (objIds2.Length <= 0) { return; } var delSols = acCurEd.GetBool("\nDelete consumed solids after performing operation? "); if (delSols == null) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { objIds1.SolidSubtrahend(objIds2, acCurDb, acTrans, delSols.Value); acTrans.Commit(); } }
/// <summary> /// TODO /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Load_Click(object sender, EventArgs e) { try { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; if (acCurDoc == null) { return; } var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (acCurDoc.LockDocument()) { using (var extDb = acCurEd.GetExternalDatabase()) { if (extDb == null) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { acCurDb.CopyAllLayers(acCurEd, extDb, acTrans); acTrans.Commit(); } PopulatePal(); } } } catch (Exception exception) { Console.WriteLine(exception); } }
public void Cmd_CleanSols() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var objIds = acCurEd.SelectAllOfType("3DSOLID", acTrans); if (objIds.Length > 0) { objIds.Clean(acCurDb, acTrans); } acTrans.Commit(); } }
public void Cmd_RcUpdate() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var objIds = acCurEd.SelectAllOfType("3DSOLID", acTrans); using (var pWorker = new ProgressAgent("Updating Solids:", objIds.Length)) { foreach (var obj in objIds) { if (!pWorker.Progress()) { acTrans.Abort(); return; } var acSol = acTrans.GetObject(obj, OpenMode.ForRead) as Solid3d; if (acSol == null) { continue; } acSol.Update(acCurDb, acTrans); } } acCurEd.WriteMessage($"\n{objIds.Length} objects updated."); acTrans.Commit(); } RcLeader.UpdateMleaders(); }
/// <summary> /// TODO /// </summary> private void CreatePal() { if (!LicensingAgent.Check()) { return; } if (_rcPal == null) { _rcPal = new PaletteSet(_palName, new Guid("395249C2-4C1A-4CD1-9422-B6BBA800ED32")) { Style = PaletteSetStyles.ShowPropertiesMenu | PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton }; _palPanel = new UserControl(); PopulatePal(); //_palPanel.UpdateTheme(); _rcPal.Add(_palName, _palPanel); } _rcPal.Visible = true; }
public void Cmd_ShrinkWrap() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var objects = acCurEd.SelectAllOfType("*TEXT", acTrans); foreach (var obj in objects) { var mText = acTrans.GetObject(obj, OpenMode.ForRead) as MText; if (mText == null) { continue; } mText.Upgrade(); if (mText.ColumnCount == 1) { mText.ColumnType = ColumnType.NoColumns; mText.Width = mText.ActualWidth; mText.Height = mText.ActualHeight; } mText.Downgrade(); } acTrans.Commit(); } }
public void Cmd_DimUpdate() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var dimIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Dimension, false, null, "\nSelect dimensions to update to current dimension style: "); if (dimIds.Length <= 0) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var obj in dimIds) { var acDim = acTrans.GetObject(obj, OpenMode.ForRead) as Dimension; if (acDim == null) { return; } acDim.Upgrade(); acDim.DimensionStyle = acCurDb.Dimstyle; acDim.Downgrade(); } acTrans.Commit(); } }
public void Cmd_WeldMark() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; _ = acCurDoc.Editor; try { Entity jigEnt = WeldJig.Jig(out var arrowStart, out var symStart); var jigId = ObjectId.Null; if (jigEnt == null) { //jigEnt.Dispose(); return; } jigId = acCurDb.AppendEntity(jigEnt); Line line = null; var lineId = ObjectId.Null; var leftFacing = false; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var arrowPt = new Point2d(arrowStart.X, arrowStart.Y); var symPt = new Point2d(symStart.X, symStart.Y); var angle = arrowPt.AngleBetween(symPt); var dDimScale = (double)Application.GetSystemVariable("DIMSCALE"); var length = SettingsUser.WeldSymbolLength * dDimScale; if (angle > 90 || angle < -90) { length = -length; leftFacing = true; } line = new Line(symStart, new Point3d(symStart.X + length, symStart.Y, 0)); lineId = acCurDb.AppendEntity(line, acTrans); acTrans.Commit(); } var weldGui = new WeldGui(line.StartPoint, line.EndPoint); weldGui.LeftFacing = leftFacing; var result = weldGui.ShowDialog(); TransientAgent.Clear(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { if (result == DialogResult.OK) { foreach (var ent in weldGui.drawnEnts) { acCurDb.AppendEntity(ent, acTrans); } } else { var jigDel = acTrans.GetObject(jigId, OpenMode.ForWrite) as Entity; if (jigDel != null) { jigDel.Erase(); jigDel.Dispose(); } var lineDel = acTrans.GetObject(lineId, OpenMode.ForWrite) as Entity; if (lineDel != null) { lineDel.Erase(); lineDel.Dispose(); } line.Dispose(); } acTrans.Commit(); } weldGui.Dispose(); Utils.SetFocusToDwgView(); } catch (Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } }
public void Cmd_OutputParts() { if (!LicensingAgent.Check()) { return; } // Get the current document var acCurDoc = Application.DocumentManager.MdiActiveDocument; if (acCurDoc == null) { return; } using (acCurDoc.LockDocument()) { //Get the current database and editor var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, false, null, "\nSelect 3D Solids to save out into separate files: "); if (objIds.Length <= 0) { return; } //Tell the user we are going to open a dialog window to select a directory acCurEd.WriteMessage("\nSelect directory to export parts to"); var dirSelected = false; // Get the directory to save to var fDirectory = string.Empty; //While user has not chosen a directory, or until user cancels - show a dialog window for directory selection while (dirSelected == false) { //Create the folder browser var fBrowser = new FolderBrowser(); var result = fBrowser.ShowDialog(new AcadMainWindow()); //If the folder browser selection worked: if (result != DialogResult.OK) { if (result == DialogResult.Cancel) { acCurEd.WriteMessage("\nOperation cancelled by user."); return; } acCurEd.WriteMessage("\nError in selection - Aborting operation."); return; } fDirectory = fBrowser.DirectoryPath; dirSelected = true; } #region Old File Handling if (!new PathFinder().IsDirectoryEmpty(fDirectory)) { var subPath = "\\_OldVersions" + DateTime.Now.ToString(" MM.dd [HH.mm.ss]"); var exists = Directory.Exists(fDirectory + subPath); if (exists) { return; } try { // Ensure the source directory exists if (Directory.Exists(fDirectory)) { // Ensure the destination directory doesn't already exist if (Directory.Exists(fDirectory + subPath) == false) { var destDir = fDirectory + subPath; Directory.CreateDirectory(destDir); var files = Directory.EnumerateFiles(fDirectory, "*") .Select(path => new FileInfo(path)); var folders = Directory.EnumerateDirectories(fDirectory, "*") .Select(path => new DirectoryInfo(path)); foreach (var file in files) { try { file.MoveTo(Path.Combine(destDir, file.Name)); } catch (Exception e) { MessageBox.Show("File " + file.Name + " is currently in use and cannot be moved."); Console.WriteLine(e); } } foreach (var folder in folders) { try { if (!folder.Name.Contains("OldVersions")) { folder.MoveTo(Path.Combine(destDir, folder.Name)); } } catch (Exception e) { MessageBox.Show("Folder " + folder.Name + " is currently in use and cannot be moved."); Console.WriteLine(e); } } } } } catch (Exception e) { MessageBox.Show(e.Message); return; } } #endregion acCurEd.WriteMessage("\nDirectory selected: " + fDirectory); var eList = new List <EntInfo>(); var multAmount = 1; if (SettingsUser.PromptForMultiplication) { multAmount = acCurEd.GetPositiveInteger("\nEnter number to multiply parts by: ", 1); } using (var pWorker = new ProgressAgent("Parsing Solids: ", objIds.Length)) { using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var objId in objIds) { //Progress progress bar or exit if ESC has been pressed if (!pWorker.Progress()) { acTrans.Abort(); return; } var acSol = acTrans.GetObject(objId, OpenMode.ForRead) as Solid3d; if (acSol == null) { continue; } eList.Add(new EntInfo(acSol, acCurDb, acTrans)); } eList.SortAndExport(fDirectory, pWorker, acCurDb, acCurEd, acTrans, multAmount); acTrans.Commit(); } } } }
public void Cmd_DimMove() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system to move: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; var addMatrix = acCurEd.GetAlignedMatrix(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); var prPtOpts = new PromptPointOptions("\nSelect new position for dimensions: "); while (true) { dimSys.Highlight(); var nArray = DimSystem.GetActiveViewCount(); var ctManager = TransientManager.CurrentTransientManager; var intCol = new IntegerCollection(nArray); var rotatedDimensions = new List <RotatedDimension>(); foreach (var dim in dimSys.SysList) { var dimClone = (RotatedDimension)dim.Clone(); ctManager.AddTransient(dimClone, TransientDrawingMode.Highlight, 128, intCol); rotatedDimensions.Add(dimClone); } void Handler(object sender, PointMonitorEventArgs e) { foreach (var tDim in rotatedDimensions) { if (!tDim.UsingDefaultTextPosition) { var dimLinePoint = tDim.DimLinePoint; var textPosition = tDim.TextPosition; tDim.DimLinePoint = e.Context.ComputedPoint; ctManager.UpdateTransient(tDim, intCol); tDim.TextPosition = textPosition.Add(dimLinePoint.GetVectorTo(tDim.DimLinePoint)); } else { tDim.DimLinePoint = e.Context.ComputedPoint; } ctManager.UpdateTransient(tDim, intCol); } } acCurEd.PointMonitor += Handler; PromptPointResult prRes; try { prRes = acCurEd.GetPoint(prPtOpts); } finally { acCurEd.PointMonitor -= Handler; foreach (var acRotRim in rotatedDimensions) { ctManager.EraseTransient(acRotRim, intCol); acRotRim.Dispose(); } } if (prRes.Status != PromptStatus.OK) { break; } dimSys.MoveSystem(prRes.Value.TransformBy(addMatrix), eqPoint); acTrans.TransactionManager.QueueForGraphicsFlush(); } dimSys.Unhighlight(); } } acTrans.Commit(); } }
public void Cmd_MatchViews() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var viewRes = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Viewport, false, null, "\nSelect Viewports to resize: "); if (viewRes.Length <= 0) { return; } var alignRes = acCurEd.GetFilteredSelection(Enums.DxfNameEnum.Viewport, true, null, "\nSelect Viewport to match: "); if (alignRes.Length <= 0) { return; } const string key1 = "Height"; const string key2 = "Width"; const string key3 = "Both"; var keyRes = acCurEd.GetSimpleKeyword("Match which size: ", new[] { key1, key2, key3 }); if (string.IsNullOrEmpty(keyRes)) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var mainViewport = acTrans.GetObject(alignRes[0], OpenMode.ForRead) as Viewport; if (mainViewport == null) { return; } var mainHeight = mainViewport.Height; var mainWidth = mainViewport.Width; var mainBounds = mainViewport.Bounds; if (mainBounds == null) { return; } _ = mainBounds.Value.MaxPoint.Y; _ = mainBounds.Value.MinPoint.Y; _ = mainBounds.Value.MinPoint.X; _ = mainBounds.Value.MaxPoint.X; foreach (var objId in viewRes) { var alignView = acTrans.GetObject(objId, OpenMode.ForWrite) as Viewport; if (alignView == null) { continue; } switch (keyRes) { case key1: //Height alignView.Height = mainHeight; break; case key2: //Width alignView.Width = mainWidth; break; case key3: //Both alignView.Height = mainHeight; alignView.Width = mainWidth; break; } } acTrans.Commit(); } }
public void Cmd_CrossJoint() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var cutId = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, true, null, "\nSelect 3D Solid to cut: "); if (cutId.Length <= 0) { return; } var cutterId = acCurEd.GetFilteredSelection(Enums.DxfNameEnum._3Dsolid, true, null, "\nSelect 3D Solid use as cutter: "); if (cutterId.Length <= 0) { return; } using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var objToCut = acTrans.GetObject(cutId[0], OpenMode.ForWrite) as Solid3d; var objCutter = acTrans.GetObject(cutterId[0], OpenMode.ForWrite) as Solid3d; if (objToCut != null && objCutter != null) { var toCutClone = objToCut.Clone() as Solid3d; var cutterClone = objCutter.Clone() as Solid3d; if (cutterClone != null && toCutClone != null) { toCutClone.BooleanOperation(BooleanOperationType.BoolIntersect, cutterClone); acCurDb.AppendEntity(toCutClone, acTrans); var gExt = toCutClone.GeometricExtents; var gCen = gExt.MinPoint.GetMidPoint(gExt.MaxPoint); var gPlane = new Plane(gCen, acCurEd.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis); try { var slicedObj = toCutClone.Slice(gPlane, true); acCurDb.AppendEntity(slicedObj, acTrans); objToCut.BooleanOperation(BooleanOperationType.BoolSubtract, toCutClone); objCutter.BooleanOperation(BooleanOperationType.BoolSubtract, slicedObj); } catch (Exception e) { Console.WriteLine(e); MailAgent.Report(e.Message); throw; } } } acTrans.Commit(); } }