sandiegophil Posted September 2, 2012 Share Posted September 2, 2012 (edited) Hello all, I am trying to find a way to export all existing styles and their settings from my template file to a format like txt, word, excel etc. Has anyone found a successful way to accomplish this without using hundreds of print-screens? Any and all help is greatly appreciated. Regards, Phil p.s. It would also be great to include all of the settings from the tabs in the "Drawing Setting" window. Edited September 3, 2012 by sandiegophil major point missing from post Quote Link to comment Share on other sites More sharing options...
Emigrato Posted September 2, 2012 Share Posted September 2, 2012 Without exporting styles&settings, try to _COPYBASE everything from your project drawing, and _PASTEORIG in an empty .DWG based on your template. Quote Link to comment Share on other sites More sharing options...
sandiegophil Posted September 2, 2012 Author Share Posted September 2, 2012 Emigrato, Thanks very much for your reply. It seems I was not very clear about one aspect of my question/request. I am looking to export the data to an editable/printable format. Something like a txt file, excel format etc. Best regards, Phil Quote Link to comment Share on other sites More sharing options...
caddcop Posted September 3, 2012 Share Posted September 3, 2012 This link is for a utility that allows export and import of settings between 2010 and 2011. http://www.inmotioncon.com/software/imC3DStgs.aspx The file it creates is actually a zip file - even though the extension is not zip. In the file are some DWG's of blocks, text styles, dimension styles and layers (this is from memory, so it might be a little different.) Finally, there are two xml files - even though only one has an XML extension. In the one with the non-xml extension, are all of the settings. The issue of reading these into excel is that excel can read XML files, but only pieces at a tie and the way it reads them is not 100% conducive to your goals. I have created style sheets that can process XML files into html pages and am trying to do the same with this file, but so far it has not worked. I have also communicated with the programmer who developed this tool. He is no longer with the company but is in negotiations with them to continue the development as a joint product with his new firm. I am still on my 30 day free trial so I do not know if they are even honoring new sales at this time. But with it only being for 2010 and 2011, I an reluctant to continue pursuing a purchase if it becomes an obsolete tool. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 3, 2012 Share Posted September 3, 2012 FWIW - To the topic of Importing and Exporting Civil 3D Styles... This post may be helpful, depending on what version you have, and uses the built-in ImportStylesAndSettings Command. As for exporting the Styles and Settings to file... While you can access the Style Property Object for some AECC* Objects (i.e., (vlax-dump-object (vlax-get 'style) T) ), I've not looked into accessing the Styles Collection Object itself. If possible through Visual LISP (COM API) this post may be of use, otherwise, you'll need to look to .NET API. Quote Link to comment Share on other sites More sharing options...
sandiegophil Posted September 4, 2012 Author Share Posted September 4, 2012 caddcop and RenderMan, Thank you both for the very helpful information. I am in the position that any "pay" items would come out of my pocket based on the procurement process where I work. If you happen across anything similar, please let me know. Regards, Phil Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 4, 2012 Share Posted September 4, 2012 Phil, what I suggested will not cost you any money.... You simply need to dig through the AeccXUiLand.AeccApplication*, AeccXUiPipe.AeccPipeApplication*, AeccXUiRoadway.AeccRoadwayApplication*, and AeccXUiSurvey.AeccSurveyApplication* [External] Objects for the information you're after. ** Just be sure to properly use vlax-Release-Object when done (or if an *error* occurs) so as to not cause undesired behavior. Quote Link to comment Share on other sites More sharing options...
sandiegophil Posted September 4, 2012 Author Share Posted September 4, 2012 RenderMan, I'm sure your suggestion would provide the information however I don't write code and am not familiar with what direction you provided. Thanks, Phil Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 4, 2012 Share Posted September 4, 2012 ... I don't write code and am not familiar with what direction you provided. Ah, yes - of course... I'll see what I can throw together quickly (in pieces?), and post back. Quote Link to comment Share on other sites More sharing options...
caddcop Posted September 4, 2012 Share Posted September 4, 2012 They offer a 30 day free trial with no credit card or other hooks. You only enter a company name and email and it works for 30 days - more than enough time to extract a lot of template data. On the other hand, when you look at the data in an XML or text editor, you may be overwhelmed with the volume of information. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 4, 2012 Share Posted September 4, 2012 FWIW - There's a .NET sample for exporting Command Settings to .XML already included in the Sample folder for your installation here: (defun c:C3dCsSample (/ folder) (if (setq folder (findfile (strcat (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key ; If 2013 (vlax-user-product-key) ; Use 2013 function (vlax-product-key) ; Use legacy function ) ) "ACADLOCATION" ) "\\Sample\\Civil 3D API\\DotNet\\CSharp\\CommandSettingsSample" ) ) ) (startapp "explorer" folder) (prompt "\n** Folder not found ** ") ) (princ) ) I've taken the liberty of compiling this sample .NET code to .NET 3.5, which should work for Civil 3D 2010 and newer. Simply rename the file from CommandSettings.txt to CommandSettings.dll Once you've NETLOADed the assembly, simply enter in the CommandMethod name of "ExportCS" Again, this is only a sample... For those who would prefer (as I do), to compile the source code themselves: using System; using System.Text; using Autodesk.AutoCAD.Runtime; using Autodesk.Civil.ApplicationServices; using Autodesk.Civil.Settings; using System.Reflection; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.EditorInput; using System.Collections; using Autodesk.AutoCAD.Windows; using System.IO; namespace CommandSettingsSample { /// <summary> /// This sample illustrates the Civil 3D .NET Command Settings API /// It exports a list of all command settings in one Civil document as /// an xml document. /// </summary> public class CSSample { public Editor ed; public StringBuilder xml; public String file; /// <summary> /// Command to export command settings. /// </summary> [CommandMethod("ExportCS")] public void ExportCommandSettings() { var sfd = new System.Windows.Forms.SaveFileDialog(); sfd.Filter = "XML Files (*.xml)|*.xml"; sfd.DefaultExt = "xml"; sfd.FileName = "cmd_settings.xml"; sfd.Title = "Export command settings"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { file = sfd.FileName; } else { return; } CivilDocument doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument; ed = Application.DocumentManager.MdiActiveDocument.Editor; xml = new StringBuilder(); // Get all the settings defined in AeccDbMgd using Reflection Type[] types = new Type[] { typeof(Autodesk.Civil.Settings.SettingsRoot) }; Assembly aeccdbmgd = typeof(CivilDocument).Module.Assembly; Type[] types2 = aeccdbmgd.GetTypes(); foreach (Type t in types2) { // A command setting's class name contains "SettingsCmd", and is derived from SettingsAmbient (or // derived from a child of SettingsAmbient) if (t.Name.Contains("SettingsCmd") && (t.BaseType.Name.Contains("SettingsAmbient") || t.BaseType.BaseType.Name.Contains("SettingsAmbient"))) { ed.WriteMessage("Command Setting found: " + t.Name + "\n"); xml.Append( String.Format("<CommandSetting name=\"{0}\">\n", t.Name)); try { ConstructorInfo conInfo = t.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, types, null); object[] s4 = new object[] { doc.Settings }; SettingsAmbient settingsAmbient = (SettingsAmbient)conInfo.Invoke(s4); // This gets the properties of the class and adds it to the xml string GetPropsOfObj(settingsAmbient, 2); } catch (System.Exception e) { ed.WriteMessage("Error: " + e.Message + "\n" + e.GetType() + "\n"); } xml.Append( "</CommandSetting>\n"); } } using (var sw = new StreamWriter(file)) { sw.Write(xml.ToString()); sw.Close(); } ed.WriteMessage("DONE\n"); } /// <summary> /// Gets the properites for an object using Reflection /// </summary> /// <param name="obj">The object to inspect</param> /// <param name="tab">Tab level for xml indentation</param> private void GetPropsOfObj(Object obj, int tab) { String space = " ".PadRight(tab); Type type = obj.GetType(); PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo propInfo in properties) { object prop = type.InvokeMember(propInfo.Name, BindingFlags.GetProperty, null, obj, new object[0]); if (prop.GetType().Name.Contains("Settings")) { xml.Append(String.Format(space + "<Property name=\"{0}\">\n", propInfo.Name)); GetPropsOfObj(prop, tab + 3); xml.Append( space + "</Property>\n"); } else if (prop.GetType().Name.Contains("Property")) { Type propType = prop.GetType(); object val = propType.InvokeMember("Value", BindingFlags.GetProperty, null, prop, new object[0]); xml.Append( String.Format(space + "<Property name=\"{0}\" value=\"{1}\"/>\n", propInfo.Name, val.ToString())); } else { ed.WriteMessage("Didn't process: {0} {1}\n", propInfo.Name, propInfo.PropertyType.ToString()); } } } } } HTH CommandSettings.txt Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 4, 2012 Share Posted September 4, 2012 Forgot to mention, that the resultant .XML file may not be properly read by simply double clicking on it, as (in my case using an OOTB .DWT to test), some of the string information was written to file as: <snip> <Property name="NameFormat"> <Property name="SheetFile" value="[color=red][b]<[/b][/color][View Frame Group Name(CP)]> - ([color=red][b]<[/b][/color][Next Counter(CP)][b][color=red]>[/color][/b])"/> <Property name="Layout" value="Sheet - ([color=red][b]<[/b][/color][Next Counter(CP)][b][color=red]>[/color][/b])"/> <Property name="MatchLine" value="ML - ([color=red][b]<[/b][/color][Next Counter(CP)][b][color=red]>[/color][/b])"/> <Property name="ViewFrame" value="VF - ([color=red][b]<[/b][/color][Next Counter(CP)][b][color=red]>[/color][/b])"/> <Property name="ViewFrameGroup" value="VFG - [color=red][b]<[/b][/color][View Frame Group Alignment Name(CP)][b][color=red]>[/color][/b] - ([color=red][b]<[/b][/color][Next Counter(CP)][b][color=red]>[/color][/b])"/> </Property> <snip> ... Which causes the XML file to be unreadable to non-XML enabled readers, such as Visual Studio, Notepad++, etc.. Quote Link to comment Share on other sites More sharing options...
sandiegophil Posted September 4, 2012 Author Share Posted September 4, 2012 RenderMan, I have tried several times with no luck. this is the message i am receiving. Command: netload Cannot load assembly. Error details: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\pendrizz\Desktop\CommandSettings.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) File name: 'file:///C:\Users\pendrizz\Desktop\CommandSettings.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName) at loadmgd() Quote Link to comment Share on other sites More sharing options...
sandiegophil Posted September 4, 2012 Author Share Posted September 4, 2012 caddcop, I contacted them and was told that they do not support C3D 2012 as of yet. thanks for all your help. Phil Quote Link to comment Share on other sites More sharing options...
caddcop Posted September 5, 2012 Share Posted September 5, 2012 (edited) In this zip file is the xml from that tool. I added a line to assign a stylesheet to it and have included the stylesheet in the zip file. If you open the xml file in Internet Explorer, Firefox or even Excel, you will see some tables of the first few nodes of the xml file. The statistics from Notepad++ are as follows: 2,087,955 bytes 2,051,385 non blank characters 225,968 words 18286 lines That's a lot of data. This is from one of the NCS Imperial Templates delivered with 2011 BTW, this is a very incomplete and preliminary stylesheet. Ideally, the various data that is setup using similar formats can be processed via a shared xsl template. To read files from 2009 or earlier or 2012 and later would require some other tool. It would appear that the dll from the other reply creates a different xml file. I wonder if there are settings in the functions, properties or methods that would correct of modify the output? Settings.zip Edited September 5, 2012 by caddcop ADDITIONAL INFO Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 9, 2012 Share Posted September 9, 2012 Hi Renderman same problem get the long error message 2013 it may be something not loaded as we are externally controlled on what turns up on our pc's could it be a missing library file. We did have a problem and had to load a new .net library for something else. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 9, 2012 Share Posted September 9, 2012 (edited) Unfortunately, as I stated above, I compiled this code to .NET 3.5 for 2010 database format (which covers 2010, 2011, and 2012). 2013 is .NET 4.0, and requires an assembly reference to AcCoreMgd.dll, and may or may not include an assembly reference to XAML.dll (.NET 4.0 includes this automatically in new Visual Studio projects in my template). I do not have Civil 3D 2013 installed, so I am missing the appropriate references to AecBaseMgd.dll, and AeccDbMgd.dll (if memory serves) for 2013 specifically to compile, hence the source code wing posted above for others to compile. HTH Edited September 9, 2012 by BlackBox Typos Quote Link to comment Share on other sites More sharing options...
Jeff_M Posted September 19, 2012 Share Posted September 19, 2012 I have tried several times with no luck. this is the message i am receiving. Command: netload Cannot load assembly. Error details: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\pendrizz\Desktop\CommandSettings.dll' Phil, That message comes from 1, of 2, reasons that I am aware of. One being that you tried to load it from a network location, which it doesn't appear you are doing. The other is that you did not Unblock the ZIP file before extracting the dll. This is the most common problem, especially with Win7 since it likes to protect you from yourself so well. Anytime a file is downloaded, either from the 'net itself, or via an email attachment, if Win7 senses the file contains exe or dll files, Win7 will Block the files from running. To fix that, before any files are extracted(if a zip) or run (in the case of a renamed file), right-click the file, select Properties, at the bottom of the General tab should be a button labeled Unblock. Click that, close the properties, then extract the files (make sure to delete any files previously extracted first). Quote Link to comment Share on other sites More sharing options...
Jeff_M Posted September 19, 2012 Share Posted September 19, 2012 Renderman, for the OP's wish for the Styles to also be output, there is another sample provided which can be modified to do just that. Look at the Compare Styles sample, it has code to regenerate an ArrayList of all styles which can then be used to create an XML file (I've done this for a company) or any other format file (txt, csv, etc.). As for the Command Settings sample not outputting correctly formatted XML code, I used this as an excuse to learn how to use the .NET XML Document tools. Shoot me an email if you want more info. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 20, 2012 Share Posted September 20, 2012 Did the unblock etc netloaded now no error messages but nothing happens when you run "exportcs" "unknown command" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.