Jeff H Posted July 21, 2011 Posted July 21, 2011 Is anyone else having problems pasting code from VS2010? It puts all the code on one line and I have to paste it in VS 2008 then copy it from there but then it does not add indentions and moves all code to the begining of line. Quote
BlackBox Posted July 21, 2011 Posted July 21, 2011 I've had the same problem, Jeff... I was thinking of trying to paste to an empty notepad / word file first (the next time I has VS code to share) to see if that would help. Quote
Jeff H Posted July 21, 2011 Author Posted July 21, 2011 (edited) [color=black][font=Consolas] [[/font][/color][color=#2b91af][font=Consolas]CommandMethod[/font][/color][color=black][font=Consolas]([/font][/color][color=#a31515][font=Consolas]"ChangeDisplayThemes"[/font][/color][color=black][font=Consolas])][/font][/color] [color=blue][font=Consolas]public[/font][/color][color=blue][font=Consolas]void[/font][/color][color=black][font=Consolas] ChangeDisplayThemes()[/font][/color] [color=black][font=Consolas] {[/font][/color] [color=#2b91af][font=Consolas]Document[/font][/color][color=black][font=Consolas] doc = [/font][/color][color=#2b91af][font=Consolas]Application[/font][/color][color=black][font=Consolas].DocumentManager.MdiActiveDocument;[/font][/color] [color=#2b91af][font=Consolas]Database[/font][/color][color=black][font=Consolas] db = doc.Database;[/font][/color] [color=#2b91af][font=Consolas]Editor[/font][/color][color=black][font=Consolas] ed = doc.Editor;[/font][/color] [color=blue][font=Consolas]using[/font][/color][color=black][font=Consolas] ([/font][/color][color=#2b91af][font=Consolas]Transaction[/font][/color][color=black][font=Consolas] trx = db.TransactionManager.StartTransaction())[/font][/color] [color=black][font=Consolas] {[/font][/color] [color=#2b91af][font=Consolas]List[/font][/color][color=black][font=Consolas]<[/font][/color][color=#2b91af][font=Consolas]ObjectId[/font][/color][color=black][font=Consolas]> displayThemeIdList = [/font][/color][color=blue][font=Consolas]new[/font][/color][color=#2b91af][font=Consolas]List[/font][/color][color=black][font=Consolas]<[/font][/color][color=#2b91af][font=Consolas]ObjectId[/font][/color][color=black][font=Consolas]>(); [/font][/color] [color=#2b91af][font=Consolas]BlockTable[/font][/color][color=black][font=Consolas] bt = ([/font][/color][color=#2b91af][font=Consolas]BlockTable[/font][/color][color=black][font=Consolas])trx.GetObject(db.BlockTableId, [/font][/color][color=#2b91af][font=Consolas]OpenMode[/font][/color][color=black][font=Consolas].ForRead);[/font][/color] [color=#2b91af][font=Consolas]BlockTableRecord[/font][/color][color=black][font=Consolas] modelSpace = ([/font][/color][color=#2b91af][font=Consolas]BlockTableRecord[/font][/color][color=black][font=Consolas])trx.GetObject(bt[[/font][/color][color=#2b91af][font=Consolas]BlockTableRecord[/font][/color][color=black][font=Consolas].ModelSpace], [/font][/color][color=#2b91af][font=Consolas]OpenMode[/font][/color][color=black][font=Consolas].ForRead);[/font][/color] [color=blue][font=Consolas]foreach[/font][/color][color=black][font=Consolas] ([/font][/color][color=#2b91af][font=Consolas]ObjectId[/font][/color][color=black][font=Consolas] objId [/font][/color][color=blue][font=Consolas]in[/font][/color][color=black][font=Consolas] modelSpace)[/font][/color] [color=black][font=Consolas] {[/font][/color] [color=blue][font=Consolas]if[/font][/color][color=black][font=Consolas] (objId.ObjectClass.Name == [/font][/color][color=#a31515][font=Consolas]"AecDbDisplayTheme"[/font][/color][color=black][font=Consolas])[/font][/color] [color=black][font=Consolas] {[/font][/color] [color=black][font=Consolas] displayThemeIdList.Add(objId);[/font][/color] [color=black][font=Consolas] }[/font][/color] [color=black][font=Consolas] } [/font][/color] [color=#2b91af][font=Consolas]DisplayRepresentationManager[/font][/color][color=black][font=Consolas] disRepMngr = [/font][/color][color=blue][font=Consolas]new[/font][/color][color=#2b91af][font=Consolas]DisplayRepresentationManager[/font][/color][color=black][font=Consolas](db);[/font][/color] [color=#2b91af][font=Consolas]DisplayConfiguration[/font][/color][color=black][font=Consolas] currentDisplayConfig =[/font][/color] [color=black][font=Consolas] disRepMngr.DisplayConfigurationIdForCurrentViewport.GetObject([/font][/color][color=#2b91af][font=Consolas]OpenMode[/font][/color][color=black][font=Consolas].ForWrite) [/font][/color][color=blue][font=Consolas]as[/font][/color][color=#2b91af][font=Consolas]DisplayConfiguration[/font][/color][color=black][font=Consolas]; [/font][/color] [color=#2b91af][font=Consolas]ObjectId[/font][/color][color=black][font=Consolas] displayThemeId = displayThemeIdList[0];[/font][/color] [color=blue][font=Consolas]if[/font][/color][color=black][font=Consolas] (currentDisplayConfig.DisplayTheme == displayThemeId)[/font][/color] [color=black][font=Consolas] {[/font][/color] [color=black][font=Consolas] displayThemeId = displayThemeIdList[1];[/font][/color] [color=black][font=Consolas] } [/font][/color] [color=black][font=Consolas] currentDisplayConfig.DetachDisplayTheme(); [/font][/color] [color=black][font=Consolas] currentDisplayConfig.AttachDisplayTheme(displayThemeId); [/font][/color] [color=black][font=Consolas] trx.Commit();[/font][/color] [color=black][font=Consolas] }[/font][/color] [color=black][font=Consolas] ed.Regen();[/font][/color] [color=black][font=Consolas] }[/font][/color] [CommandMethod("ChangeDisplayThemes")] public void ChangeDisplayThemes() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction trx = db.TransactionManager.StartTransaction()) { List<ObjectId> displayThemeIdList = new List<ObjectId>(); BlockTable bt = (BlockTable)trx.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord modelSpace = (BlockTableRecord)trx.GetObject(bt[blockTableRecord.ModelSpace], OpenMode.ForRead); foreach (ObjectId objId in modelSpace) { if (objId.ObjectClass.Name == "AecDbDisplayTheme") { displayThemeIdList.Add(objId); } } DisplayRepresentationManager disRepMngr = new DisplayRepresentationManager(db); DisplayConfiguration currentDisplayConfig = disRepMngr.DisplayConfigurationIdForCurrentViewport.GetObject(OpenMode.ForWrite) as DisplayConfiguration; ObjectId displayThemeId = displayThemeIdList[0]; if (currentDisplayConfig.DisplayTheme == displayThemeId) { displayThemeId = displayThemeIdList[1]; } currentDisplayConfig.DetachDisplayTheme(); currentDisplayConfig.AttachDisplayTheme(displayThemeId); trx.Commit(); } ed.Regen(); } Edited August 2, 2011 by Jeff H Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 Jeff, I had a thought... Are you using a guide-line to format your code in VS? On my iPhone now so I'll have to post code tomorrow. However, when I pasted some VB.NET earlier, it seemed to come in fine with exception of the indentation. The code I pasted was without guide-line and had a manual "enter" after each line. Just a thought. Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 Here's a screen shot of what my code looks like in VS (which includes hard, or manual Enters after each line): ... And here is the code pasted into this post: [font=Consolas][size=2][font=Consolas][size=2]<[/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]CommandMethod[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"Q"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2])> _[/size][/font] [/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Public[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Sub[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] Q()[/size][/font] [/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Dim[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] ed [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Editor[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] = [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Application[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].DocumentManager.MdiActiveDocument.Editor[/size][/font] [/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Application[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].GetSystemVariable([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"mbuttonpan"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]) = 1 [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Then[/color][/size][/font] [/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Application[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].SetSystemVariable([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"mbuttonpan"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2], 0)[/size][/font] [size=2][font=Consolas]ed.WriteMessage(vbLf & [/font][/size][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"MBUTTONPAN: OFF "[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2])[/size][/font] [/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Else[/color][/size][/font] [/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Application[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].SetSystemVariable([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"mbuttonpan"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2], 1)[/size][/font] [size=2][font=Consolas]ed.WriteMessage(vbLf & [/font][/size][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"MBUTTONPAN: ON "[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2])[/size][/font] [/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font] [/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Sub[/color][/size][/font] [/color][/size][/font][/color][/size][/font] Edit: Not only is all indentation removed, but also all preceding spaces, for example "PublicSub" should be "Public Sub", etc. Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 Interestingly, when the code (VB.NET in this case) is pasted into Notepad, the formatting remains (minus the text color): Screen shot: ... Pasted from VS ==> Notepad ==> This post: <CommandMethod("Q")> _ Public Sub Q() Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor If Application.GetSystemVariable("mbuttonpan") = 1 Then Application.SetSystemVariable("mbuttonpan", 0) ed.WriteMessage(vbLf & "MBUTTONPAN: OFF ") Else Application.SetSystemVariable("mbuttonpan", 1) ed.WriteMessage(vbLf & "MBUTTONPAN: ON ") End If End Sub Here is the code as pasted into Word: Screen shot: ... Pasted from VS ==> Word ==> This post: [font=Consolas][font=Consolas] <[color=#2b91af]CommandMethod[/color]([color=#a31515]"Q"[/color])> _[/font] [font=Consolas] [color=blue]Public[/color] [color=blue]Sub[/color] Q()[/font] [font=Consolas] [color=blue]Dim[/color] ed [color=blue]As[/color] [color=#2b91af]Editor[/color] = [color=#2b91af]Application[/color].DocumentManager.MdiActiveDocument.Editor[/font] [font=Consolas] [color=blue]If[/color] [color=#2b91af]Application[/color].GetSystemVariable([color=#a31515]"mbuttonpan"[/color]) = 1 [color=blue]Then[/color][/font] [font=Consolas] [color=#2b91af]Application[/color].SetSystemVariable([color=#a31515]"mbuttonpan"[/color], 0)[/font] [font=Consolas] ed.WriteMessage(vbLf & [color=#a31515]"MBUTTONPAN: OFF "[/color])[/font] [font=Consolas] [color=blue]Else[/color][/font] [font=Consolas] [color=#2b91af]Application[/color].SetSystemVariable([color=#a31515]"mbuttonpan"[/color], 1)[/font] [font=Consolas] ed.WriteMessage(vbLf & [color=#a31515]"MBUTTONPAN: ON "[/color])[/font] [font=Consolas] [color=blue]End[/color] [color=blue]If[/color][/font] [font=Consolas] [color=blue]End[/color] [color=blue]Sub[/color][/font] [/font] Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 FWIW - I did try pasting the C# code posted above into C#VSE 2010 and all code came in on one line within VS. That is what made me think of the "guide-line" usage. HTH Quote
Jeff H Posted August 2, 2011 Author Posted August 2, 2011 Thanks for the info but I am not using 'guideline' maybe I will try pasting in Notepad or word but I thought I tried that with C# Quote
Jeff H Posted August 2, 2011 Author Posted August 2, 2011 I edited 3rd reply by pasting in Word then here the indentation is still messed up but much better. The second one is using Notepad and that works great. Thanks RenderMan Quote
BlackBox Posted August 2, 2011 Posted August 2, 2011 Thanks RenderMan Happy I couold help. :wink: Quote
Lee Mac Posted August 2, 2011 Posted August 2, 2011 Just out of curiosity, what happens if you try saving the file from VS and from notepad, then reading each file using say, ([color=BLUE]defun[/color] c:doit ( [color=BLUE]/[/color] file fob fso res str sys tlb ) [color=GREEN];;---------------------------------------[/color] [color=GREEN];; Read as Text Stream, Lee Mac 2011 [/color] [color=GREEN];;---------------------------------------[/color] ([color=BLUE]if[/color] ([color=BLUE]setq[/color] file ([color=BLUE]getfiled[/color] [color=MAROON]"Select File"[/color] [color=MAROON]""[/color] [color=MAROON]""[/color] 16)) ([color=BLUE]vl-catch-all-apply[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] [color=BLUE]nil[/color] ([color=BLUE]setq[/color] fso ([color=BLUE]vlax-create-object[/color] [color=MAROON]"Scripting.FileSystemObject"[/color])) ([color=BLUE]if[/color] ([color=BLUE]not[/color] fso-getfile) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] sys ([color=BLUE]vlax-invoke[/color] fso 'getspecialfolder 1) tlb ([color=BLUE]strcat[/color] ([color=BLUE]vlax-get[/color] sys 'path) [color=MAROON]"\\scrrun.dll"[/color]) ) ([color=BLUE]vlax-import-type-library[/color] [color=BLUE]:tlb-filename[/color] tlb [color=BLUE]:methods-prefix[/color] [color=MAROON]"fso-"[/color] [color=BLUE]:properties-prefix[/color] [color=MAROON]"fso-"[/color] [color=BLUE]:constants-prefix[/color] [color=MAROON]":fso"[/color] ) ) ) ([color=BLUE]setq[/color] fob ([color=blue]fso-getfile[/color] fso file) str ([color=blue]fso-opentextfile[/color] fso file [color=blue]:fsoforreading[/color] [color=BLUE]nil[/color] [color=blue]:fsotristateusedefault[/color]) res ([color=blue]fso-read[/color] str ([color=blue]fso-get-size[/color] fob)) ) ([color=blue]fso-close[/color] str) ) ) ) ) ([color=BLUE]foreach[/color] obj ([color=BLUE]list[/color] str fob sys fso) ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vlax-release-object[/color] ([color=BLUE]list[/color] obj)) ) res ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Are the outputs different? Quote
Jeff H Posted August 3, 2011 Author Posted August 3, 2011 I do not know much about LISP Do I save the code as a lsp file and appload it then call doit? Quote
Lee Mac Posted August 3, 2011 Posted August 3, 2011 Do I save the code as a lsp file and appload it then call doit? Yep, you got it The function just reads a file (any file) byte by byte so you can see if VS is adding (or rather not adding) carriage returns / new line chars etc. Quote
BlackBox Posted August 3, 2011 Posted August 3, 2011 I do not know much about LISP Do I save the code as a lsp file and appload it then call doit? You can... but you do not have to. For quickly testing something, I'd simply open the Visual LISP IDE (using the VLIDE command), and open a new file, Copy+Paste the code into the new file, and load the code into the Active Document. Call. More info on the Visual LISP IDE (^^ Dude, I am SO an unofficial sales-rep lmao ^^) Quote
Jeff H Posted August 3, 2011 Author Posted August 3, 2011 It read it but it still has the 10 13 char for endline == \r\n Quote
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.