{"id":2054,"date":"2014-02-25T17:08:19","date_gmt":"2014-02-25T16:08:19","guid":{"rendered":"https:\/\/www.modelical.com\/?p=348"},"modified":"2022-05-10T17:52:02","modified_gmt":"2022-05-10T15:52:02","slug":"assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net","status":"publish","type":"post","link":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/","title":{"rendered":"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET"},"content":{"rendered":"<p>Sometimes you might want to assign a certain PlotStyle to all the layouts in an drawing. That is what this function is for. It takes a string as argument and if the PlotStyle name is found in the current dictionary, will assign it to every layout.<\/p>\n<p>This post was inspired by <a href=\"http:\/\/adndevblog.typepad.com\/autocad\/2012\/07\/gets-and-sets-the-current-plot-style-for-a-layout.html\" target=\"_blank\" rel=\"noopener\">another from the AutoCAD DevBlog.<\/a><\/p>\n<p>As always, feel free to use, improve and share.<\/p>\n<pre class=\"wrap:true lang:c# decode:true \" title=\"Assign an Named PlotStyle to all layouts in an AutoCAD drawing.\">public void SetPlotSheet(string plotStyleToSet)\r\n{\r\n\tDocument doc = Application.DocumentManager.MdiActiveDocument;\r\n    Database db = doc.Database;\r\n    Editor ed = doc.Editor;\r\n    using (Transaction tr = db.TransactionManager.StartTransaction())\r\n    {\r\n\t\tDBDictionary lays = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary;\r\n\t\tforeach (DBDictionaryEntry item in lays)\r\n\t\t{\r\n\t\t\tObjectId layoutId = item.Value;\r\n\r\n\t\t\tLayout layout = tr.GetObject(layoutId, OpenMode.ForWrite) as Layout;\r\n\t\t\tPlotSettingsValidator plotSetVal = PlotSettingsValidator.Current;\r\n\t\t\tplotSetVal.RefreshLists(layout);\r\n\r\n\t\t\tSystem.Collections.Specialized.StringCollection sheetList = plotSetVal.GetPlotStyleSheetList();\r\n\t\t\tSystem.Object test = Application.GetSystemVariable(\"PSTYLEMODE\");\r\n\t\t\tif (test.ToString().Equals(\"0\") &amp;&amp; (sheetList.Contains(plotStyleToSet)))\r\n\t\t\t{\r\n\t\t\t\tplotSetVal.SetCurrentStyleSheet(layout, plotStyleToSet);\r\n\t\t\t\ted.WriteMessage(\"nThe plot style sheet is being set to {0}nn\", plotStyleToSet);\r\n\t\t\t} else{\r\n\t\t\t\ted.WriteMessage(\"nUnable to set plot style in this file. Either the drawing is in CTB mode or the required Style does not exist in this context.nn\");\r\n\t\t   }\r\n\t\t}\r\n\r\n    \ttr.Commit();\r\n\t}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you might want to assign a certain PlotStyle to all the layouts in an drawing. That is what this function is for. It takes a string as argument and if the PlotStyle name is found in the current dictionary, will assign it to every layout. This post was inspired by another from the AutoCAD [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":27201,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[766],"class_list":["post-2054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guidelines","tag-technology-autocad"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical\" \/>\n<meta property=\"og:description\" content=\"Sometimes you might want to assign a certain PlotStyle to all the layouts in an drawing. That is what this function is for. It takes a string as argument and if the PlotStyle name is found in the current dictionary, will assign it to every layout. This post was inspired by another from the AutoCAD [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/\" \/>\n<meta property=\"og:site_name\" content=\"Modelical\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Modelical\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-25T16:08:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-10T15:52:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.modelical.com\/wp-content\/uploads\/Posts_40_Autocad.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"375\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Roberto Molinos\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@modelical\" \/>\n<meta name=\"twitter:site\" content=\"@modelical\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Roberto Molinos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/\"},\"author\":{\"name\":\"Roberto Molinos\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\"},\"headline\":\"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET\",\"datePublished\":\"2014-02-25T16:08:19+00:00\",\"dateModified\":\"2022-05-10T15:52:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/\"},\"wordCount\":78,\"image\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/PloteadoAutocad.NET-400x250-1.jpg\",\"keywords\":[\"Tec AutoCad\"],\"articleSection\":[\"Guidelines\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/\",\"name\":\"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/PloteadoAutocad.NET-400x250-1.jpg\",\"datePublished\":\"2014-02-25T16:08:19+00:00\",\"dateModified\":\"2022-05-10T15:52:02+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/PloteadoAutocad.NET-400x250-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/PloteadoAutocad.NET-400x250-1.jpg\",\"width\":400,\"height\":250},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/\",\"name\":\"Modelical\",\"description\":\"We build information\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\",\"name\":\"Roberto Molinos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"caption\":\"Roberto Molinos\"},\"sameAs\":[\"https:\\\/\\\/www.modelical.com\"],\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/author\\\/roberto\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/","og_locale":"en_US","og_type":"article","og_title":"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical","og_description":"Sometimes you might want to assign a certain PlotStyle to all the layouts in an drawing. That is what this function is for. It takes a string as argument and if the PlotStyle name is found in the current dictionary, will assign it to every layout. This post was inspired by another from the AutoCAD [&hellip;]","og_url":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/","og_site_name":"Modelical","article_publisher":"https:\/\/www.facebook.com\/Modelical\/","article_published_time":"2014-02-25T16:08:19+00:00","article_modified_time":"2022-05-10T15:52:02+00:00","og_image":[{"width":600,"height":375,"url":"https:\/\/www.modelical.com\/wp-content\/uploads\/Posts_40_Autocad.jpg","type":"image\/jpeg"}],"author":"Roberto Molinos","twitter_card":"summary_large_image","twitter_creator":"@modelical","twitter_site":"@modelical","twitter_misc":{"Written by":"Roberto Molinos","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/#article","isPartOf":{"@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/"},"author":{"name":"Roberto Molinos","@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5"},"headline":"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET","datePublished":"2014-02-25T16:08:19+00:00","dateModified":"2022-05-10T15:52:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/"},"wordCount":78,"image":{"@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/#primaryimage"},"thumbnailUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/02\/PloteadoAutocad.NET-400x250-1.jpg","keywords":["Tec AutoCad"],"articleSection":["Guidelines"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/","url":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/","name":"Assign a PlotStyle to all the Layouts in an AutoCAD Drawing Using .NET - Modelical","isPartOf":{"@id":"https:\/\/www.modelical.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/#primaryimage"},"image":{"@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/#primaryimage"},"thumbnailUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/02\/PloteadoAutocad.NET-400x250-1.jpg","datePublished":"2014-02-25T16:08:19+00:00","dateModified":"2022-05-10T15:52:02+00:00","author":{"@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.modelical.com\/en\/assign-a-plotstyle-to-all-the-layouts-in-an-autocad-drawing-using-net\/#primaryimage","url":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/02\/PloteadoAutocad.NET-400x250-1.jpg","contentUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/02\/PloteadoAutocad.NET-400x250-1.jpg","width":400,"height":250},{"@type":"WebSite","@id":"https:\/\/www.modelical.com\/en\/#website","url":"https:\/\/www.modelical.com\/en\/","name":"Modelical","description":"We build information","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.modelical.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5","name":"Roberto Molinos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","url":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","caption":"Roberto Molinos"},"sameAs":["https:\/\/www.modelical.com"],"url":"https:\/\/www.modelical.com\/en\/author\/roberto\/"}]}},"_links":{"self":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts\/2054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/comments?post=2054"}],"version-history":[{"count":0,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts\/2054\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/media\/27201"}],"wp:attachment":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/media?parent=2054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/categories?post=2054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/tags?post=2054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}