29/05/2024

Liệt kê tất cả plotstyle stb ctb trong AutoCAD | List all available plotstyle stb ctb in AutoCAD | AutoCAD dotNet

Ứng dụng được phát triển bởi đội ngũ AutoLISP Thật là đơn giản
    

Thông tin thêm: 👉👉👉

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);
            }
        }
    }
}


---------------------------------------------------------------------------------------------
Ứng dụng được phát triển bởi đội ngũ AutoLISP Thật là đơn giản - Tác giả ứng dụng in D2P

    

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

Hàm COUNTIFS đếm theo nhiều điều kiện trong Excel | COUNTIFS, COUNTIF | AutoLISP Reviewer

Hàm COUNTIFS đếm theo nhiều điều kiện trong Excel Cuối tháng cần biết phòng Kế toán có bao nhiêu người đi làm đủ công, bao nhiêu đơn hàng ...