1 Thêm class PlotsettingsHelperExts.cs
(Copy nội dung sau)
Code:
using Autodesk.AutoCAD.PlottingServices;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace DWG_to_PDF_Compared
{
internal static class PlotsettingsHelperExts
{
public static List<string> GetPlotstyles()
{
try
{
var dvs = new List<string>(PlotConfigManager.ColorDependentPlotStyles.OfType<string>().Union(PlotConfigManager.NamedPlotStyles.OfType<string>()));
dynamic comAcad = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
string[] stylePaths = comAcad.Preferences.Files.PrinterStyleSheetPath.Split(';');
var theList = "";
//if there are multiple paths, will need to loop through those as well
foreach (var fileName in Directory.GetFiles(stylePaths[0]))
{
if (fileName.EndsWith("tb"))
{
theList += theList == "" ? fileName : "\n" + fileName;
if (!dvs.Contains(fileName)) dvs.Add(fileName);
}
}
return dvs;
}
catch
{ }
return new List<string>();
}
}
}
2 Thêm MyCommands.cs
(Copy nội dung sau)
Code:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace DWG_to_PDF_Compared
{
public partial class MyCommands
{
[CommandMethod("ListAllAvailablePlotstyles", CommandFlags.Session)]
public static void cmd_List_All_Available_Plotstyles()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
var pst = PlotsettingsHelperExts.GetPlotstyles();
foreach (var ps in pst)
{
ed.WriteMessage("\n" + ps);
}
}
}
}
---------------------------------------------------------------------------------------------
Mọi thông tin xin liên hệ Fanpage AutoLISP Thật là đơn giản!
Cảm ơn bạn đã theo dõi!
Không có nhận xét nào:
Đăng nhận xét