I have linked a CTB file to the drawing file in autocad. Now i wanna convert the dwg to pdf using autocad api.I need to use the respective CTB file linked to the dwg while coverting.If I have a set of CTB files with me, how can I identify the respective CTB file using API in .NET?
I have linked a CTB file to the drawing file in autocad. Now i wanna convert the dwg to pdf using autocad api.I need to use the respective CTB file linked to the dwg while coverting.If I have a set of CTB files with me, how can I identify the respective CTB file using API in .NET?
CTB file (plot style sheet) used in a drawing file is associated to layouts in the drawing. So, if you want to identify what CTBs are used in a drawing file, you need to loop through all layouts in a drawing and find Layout.CurrentStyleSheet property, which is a string value of the CTB name.
Hope this answers your question.
Norman Yuan
CTB file (plot style sheet) used in a drawing file is associated to layouts in the drawing. So, if you want to identify what CTBs are used in a drawing file, you need to loop through all layouts in a drawing and find Layout.CurrentStyleSheet property, which is a string value of the CTB name.
Hope this answers your question.
Norman Yuan
I did not really get what you meant. If you could explain it, that would be wonderful. Thank you very much for your effort.
I did not really get what you meant. If you could explain it, that would be wonderful. Thank you very much for your effort.
[CommandMethod("LPS")] public static void ListPlotSettingS() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current; DBDictionary plotSettingsDict = (DBDictionary)tr.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead); foreach (DBDictionaryEntry plotSettingsEntry in plotSettingsDict) { PlotSettings plotSettings = (PlotSettings)tr.GetObject(plotSettingsEntry.Value, OpenMode.ForWrite); plotSettingsValidator.RefreshLists(plotSettings); ed.WriteMessage("PlotSettingsName: {0}\n", plotSettings.PlotSettingsName); ed.WriteMessage("\t ConfigurationName: {0}\n", plotSettings.PlotConfigurationName); ed.WriteMessage("\t LocaleMediaName: {0} ({1})\n", plotSettingsValidator.GetLocaleMediaName(plotSettings, plotSettings.CanonicalMediaName), plotSettings.CanonicalMediaName); ed.WriteMessage("\t PlotType: {0}\n", plotSettings.PlotType); ed.WriteMessage("\t PaperUnits: {0}\n", plotSettings.PlotPaperUnits); ed.WriteMessage("\t PaperSize: {0}\n", plotSettings.PlotPaperSize); ed.WriteMessage("\t PaperMargins: {0}\n", plotSettings.PlotPaperMargins); ed.WriteMessage("\t Centered: {0}\n", plotSettings.PlotCentered); ed.WriteMessage("\t Origin: {0}\n", plotSettings.PlotOrigin); ed.WriteMessage("\t Rotation: {0}\n", plotSettings.PlotRotation); if (plotSettings.UseStandardScale) ed.WriteMessage("\t StdScale: {0}\n", plotSettings.StdScale); else ed.WriteMessage("\t CustomScale: {0}\n", plotSettings.CustomPrintScale); ed.WriteMessage("\t Transparency: {0}\n", plotSettings.PlotTransparency); ed.WriteMessage("\t ViewportBorders: {0}\n", plotSettings.PlotViewportBorders); ed.WriteMessage("\t PrintLineweights: {0}\n", plotSettings.PrintLineweights); ed.WriteMessage("\t StyleSheet: {0}\n", plotSettings.CurrentStyleSheet); ed.WriteMessage("\t PlotStyles: {0}\n", plotSettings.PlotPlotStyles); ed.WriteMessage("\t ScaleLineweights: {0}\n", plotSettings.ScaleLineweights); } } }
[CommandMethod("LLS")] public static void ListLayoutPlotSettings() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; LayoutManager layoutManager = LayoutManager.Current; PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current; using (Transaction tr = db.TransactionManager.StartTransaction()) { DBDictionary layoutDict = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead); DBDictionary plotSettingsDict = (DBDictionary)tr.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead); foreach (DBDictionaryEntry layoutEntry in layoutDict) { Layout layout = (Layout)tr.GetObject(layoutEntry.Value, OpenMode.ForRead); if (layout.ModelType) continue; ed.WriteMessage("LayoutName: {0}\n", layout.LayoutName); layoutManager.CurrentLayout = layout.LayoutName; PlotSettings plotSettings = new PlotSettings(layout.ModelType); plotSettings.CopyFrom(layout); plotSettingsValidator.RefreshLists(plotSettings); ed.WriteMessage("PlotSettingsName: {0}\n", plotSettings.PlotSettingsName); ed.WriteMessage("\t ConfigurationName: {0}\n", plotSettings.PlotConfigurationName); ed.WriteMessage("\t LocaleMediaName: {0} ({1})\n", plotSettingsValidator.GetLocaleMediaName(plotSettings, plotSettings.CanonicalMediaName), plotSettings.CanonicalMediaName); ed.WriteMessage("\t PlotType: {0}\n", plotSettings.PlotType); ed.WriteMessage("\t PaperUnits: {0}\n", plotSettings.PlotPaperUnits); ed.WriteMessage("\t PaperSize: {0}\n", plotSettings.PlotPaperSize); ed.WriteMessage("\t PaperMargins: {0}\n", plotSettings.PlotPaperMargins); ed.WriteMessage("\t Centered: {0}\n", plotSettings.PlotCentered); ed.WriteMessage("\t Origin: {0}\n", plotSettings.PlotOrigin); ed.WriteMessage("\t Rotation: {0}\n", plotSettings.PlotRotation); if (plotSettings.UseStandardScale) ed.WriteMessage("\t StdScale: {0}\n", plotSettings.StdScale); else ed.WriteMessage("\t CustomScale: {0}\n", plotSettings.CustomPrintScale); ed.WriteMessage("\t Transparency: {0}\n", plotSettings.PlotTransparency); ed.WriteMessage("\t ViewportBorders: {0}\n", plotSettings.PlotViewportBorders); ed.WriteMessage("\t PrintLineweights: {0}\n", plotSettings.PrintLineweights); ed.WriteMessage("\t StyleSheet: {0}\n", plotSettings.CurrentStyleSheet); ed.WriteMessage("\t PlotStyles: {0}\n", plotSettings.PlotPlotStyles); ed.WriteMessage("\t ScaleLineweights: {0}\n", plotSettings.ScaleLineweights); } tr.Commit(); } }
[CommandMethod("LPS")] public static void ListPlotSettingS() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current; DBDictionary plotSettingsDict = (DBDictionary)tr.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead); foreach (DBDictionaryEntry plotSettingsEntry in plotSettingsDict) { PlotSettings plotSettings = (PlotSettings)tr.GetObject(plotSettingsEntry.Value, OpenMode.ForWrite); plotSettingsValidator.RefreshLists(plotSettings); ed.WriteMessage("PlotSettingsName: {0}\n", plotSettings.PlotSettingsName); ed.WriteMessage("\t ConfigurationName: {0}\n", plotSettings.PlotConfigurationName); ed.WriteMessage("\t LocaleMediaName: {0} ({1})\n", plotSettingsValidator.GetLocaleMediaName(plotSettings, plotSettings.CanonicalMediaName), plotSettings.CanonicalMediaName); ed.WriteMessage("\t PlotType: {0}\n", plotSettings.PlotType); ed.WriteMessage("\t PaperUnits: {0}\n", plotSettings.PlotPaperUnits); ed.WriteMessage("\t PaperSize: {0}\n", plotSettings.PlotPaperSize); ed.WriteMessage("\t PaperMargins: {0}\n", plotSettings.PlotPaperMargins); ed.WriteMessage("\t Centered: {0}\n", plotSettings.PlotCentered); ed.WriteMessage("\t Origin: {0}\n", plotSettings.PlotOrigin); ed.WriteMessage("\t Rotation: {0}\n", plotSettings.PlotRotation); if (plotSettings.UseStandardScale) ed.WriteMessage("\t StdScale: {0}\n", plotSettings.StdScale); else ed.WriteMessage("\t CustomScale: {0}\n", plotSettings.CustomPrintScale); ed.WriteMessage("\t Transparency: {0}\n", plotSettings.PlotTransparency); ed.WriteMessage("\t ViewportBorders: {0}\n", plotSettings.PlotViewportBorders); ed.WriteMessage("\t PrintLineweights: {0}\n", plotSettings.PrintLineweights); ed.WriteMessage("\t StyleSheet: {0}\n", plotSettings.CurrentStyleSheet); ed.WriteMessage("\t PlotStyles: {0}\n", plotSettings.PlotPlotStyles); ed.WriteMessage("\t ScaleLineweights: {0}\n", plotSettings.ScaleLineweights); } } }
[CommandMethod("LLS")] public static void ListLayoutPlotSettings() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; LayoutManager layoutManager = LayoutManager.Current; PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current; using (Transaction tr = db.TransactionManager.StartTransaction()) { DBDictionary layoutDict = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead); DBDictionary plotSettingsDict = (DBDictionary)tr.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead); foreach (DBDictionaryEntry layoutEntry in layoutDict) { Layout layout = (Layout)tr.GetObject(layoutEntry.Value, OpenMode.ForRead); if (layout.ModelType) continue; ed.WriteMessage("LayoutName: {0}\n", layout.LayoutName); layoutManager.CurrentLayout = layout.LayoutName; PlotSettings plotSettings = new PlotSettings(layout.ModelType); plotSettings.CopyFrom(layout); plotSettingsValidator.RefreshLists(plotSettings); ed.WriteMessage("PlotSettingsName: {0}\n", plotSettings.PlotSettingsName); ed.WriteMessage("\t ConfigurationName: {0}\n", plotSettings.PlotConfigurationName); ed.WriteMessage("\t LocaleMediaName: {0} ({1})\n", plotSettingsValidator.GetLocaleMediaName(plotSettings, plotSettings.CanonicalMediaName), plotSettings.CanonicalMediaName); ed.WriteMessage("\t PlotType: {0}\n", plotSettings.PlotType); ed.WriteMessage("\t PaperUnits: {0}\n", plotSettings.PlotPaperUnits); ed.WriteMessage("\t PaperSize: {0}\n", plotSettings.PlotPaperSize); ed.WriteMessage("\t PaperMargins: {0}\n", plotSettings.PlotPaperMargins); ed.WriteMessage("\t Centered: {0}\n", plotSettings.PlotCentered); ed.WriteMessage("\t Origin: {0}\n", plotSettings.PlotOrigin); ed.WriteMessage("\t Rotation: {0}\n", plotSettings.PlotRotation); if (plotSettings.UseStandardScale) ed.WriteMessage("\t StdScale: {0}\n", plotSettings.StdScale); else ed.WriteMessage("\t CustomScale: {0}\n", plotSettings.CustomPrintScale); ed.WriteMessage("\t Transparency: {0}\n", plotSettings.PlotTransparency); ed.WriteMessage("\t ViewportBorders: {0}\n", plotSettings.PlotViewportBorders); ed.WriteMessage("\t PrintLineweights: {0}\n", plotSettings.PrintLineweights); ed.WriteMessage("\t StyleSheet: {0}\n", plotSettings.CurrentStyleSheet); ed.WriteMessage("\t PlotStyles: {0}\n", plotSettings.PlotPlotStyles); ed.WriteMessage("\t ScaleLineweights: {0}\n", plotSettings.ScaleLineweights); } tr.Commit(); } }
Can't find what you're looking for? Ask the community or share your knowledge.