cant set stylesheet

cant set stylesheet

Anonymous
Not applicable
390 Views
8 Replies
Message 1 of 9

cant set stylesheet

Anonymous
Not applicable
Ok, others have had this problem and I havent seen a definative answer yet. Can anyone tell me why the following code snippet bombs when I attemp to set the stylesheet property? Setting it to an empty string works, but trying to put an actual style sheet name into it gives a runtime error. Yes, the .ctb file does exist, I tried tacking on full path, etc. no luck Thanks strStyleName = "HP1120-mono.ctb" With objLayout .PlotWithPlotStyles = True .StyleSheet = "" .StyleSheet = strStyleName .RefreshPlotDeviceInfo End With -- Perry Leets Inovec Optimization and Control Systems Eugene, Oregon
0 Likes
391 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
There is nothing wrong with the snippet. The problem, though, with a snippet is the error may be before this comes into play [such as how do you get the layout?] or because of a corrupt ctb file. Try running this routine and see what happens. *MAKE SURE* you use a ctb file that is the original supplied with your AutoCAD - *DON'T* use one you have created or edited. That's the only thing I can't check remotely. If this routine works, start going backwards - try using your ctb file. If it bombs, you have your problem; if it doesn't, revise how Test sets the objLayout to whatever you are using. Sub Test() Dim objLayout As AcadLayout Dim strStyleName As String strStyleName = "monochrome.ctb" Set objLayout = ThisDrawing.ActiveLayout With objLayout .PlotWithPlotStyles = True .StyleSheet = "" .StyleSheet = strStyleName .RefreshPlotDeviceInfo End With End Sub In article <401fccd5$1_2@newsprd01>, pleets@inovec.com says... > Ok, others have had this problem and I havent seen a definative answer yet. > Can anyone tell me why the following code snippet bombs when I attemp to set > the stylesheet property? > Setting it to an empty string works, but trying to put an actual style sheet > name into it gives a runtime error. > Yes, the .ctb file does exist, I tried tacking on full path, etc. no luck > Thanks > > > strStyleName = "HP1120-mono.ctb" > With objLayout > .PlotWithPlotStyles = True > .StyleSheet = "" > .StyleSheet = strStyleName > .RefreshPlotDeviceInfo > End With > > > -- > Perry Leets > Inovec Optimization and Control Systems > Eugene, Oregon > > > -- ___________________________ Mike Tuersley CADalyst's AutoCAD Clinic Rand IMAGINiT Technologies
0 Likes
Message 3 of 9

Anonymous
Not applicable
Thanks Mike, I'll try another .ctb file even though the one listed in the routine is the same one I use daily for ordinary plotting. I didnt even know that it made a difference on HOW you got the layout object but Ill try your snippet and as you say "work backwards" from that -- Perry Leets Inovec Optimization and Control Systems Eugene, Oregon "Mike Tuersley" wrote in message news:MPG.1a899a97f2ea308e9896b7@discussion.autodesk.com... > There is nothing wrong with the snippet. The problem, though, with a > snippet is the error may be before this comes into play [such as how do > you get the layout?] or because of a corrupt ctb file. Try running this > routine and see what happens. *MAKE SURE* you use a ctb file that is the > original supplied with your AutoCAD - *DON'T* use one you have created > or edited. That's the only thing I can't check remotely. > > If this routine works, start going backwards - try using your ctb file. > If it bombs, you have your problem; if it doesn't, revise how Test sets > the objLayout to whatever you are using. > > Sub Test() > Dim objLayout As AcadLayout > Dim strStyleName As String > strStyleName = "monochrome.ctb" > Set objLayout = ThisDrawing.ActiveLayout > With objLayout > .PlotWithPlotStyles = True > .StyleSheet = "" > .StyleSheet = strStyleName > .RefreshPlotDeviceInfo > End With > End Sub
0 Likes
Message 4 of 9

Anonymous
Not applicable
Well Mike, I get the same error with your snippet as I do mine. I wish Adesk would provide a little input on functions in their program that dont work as advertised. -- Perry Leets Inovec Optimization and Control Systems Eugene, Oregon
0 Likes
Message 5 of 9

Anonymous
Not applicable
this is what I see.. -- Perry Leets Inovec Optimization and Control Systems Eugene, Oregon
0 Likes
Message 6 of 9

Anonymous
Not applicable
Well Perry, is not Autodesk at this point. The code works so the problem is your environment. Try: A. Start a brand new drawing with no customization - use the defaut AutoCAD template. Then create a brand new dvb and paste my Test into the ThisDrawing portion and run it. What we are looking for is 1. Corruption in your dvb - in case you pasted my code into your current project 2. Corruption in your dwg file - in case you are using the same one - If this works, work backwards again. B. Try step A on another computer at your location. If it works there, but not on yours, it's uninstall/reinstall AutoCAD time. - If this fails on the other computer, then what are you doing differently??? Are the ctbs on a network drive [network corruption]? Are the drawings set for ctb, or are they set for stb? Etc. This is a pain, but the problems reported up here are rarely because of Autodesk. Usually it is the user's code, approach/methodology, support files, or system. ___________________________ Mike Tuersley CADalyst's AutoCAD Clinic Rand IMAGINiT Technologies
0 Likes
Message 7 of 9

Anonymous
Not applicable
Ok, shoot me all your specs - version of AutoCAD w/ service pack level, OS, etc. You can ignore portions of my last suggestion because I assumed you were using vba. If you try this on another box and it fails as well, can you email me your source code? ___________________________ Mike Tuersley CADalyst's AutoCAD Clinic Rand IMAGINiT Technologies
0 Likes
Message 8 of 9

Anonymous
Not applicable
If you cannot set a color dependant plot style, check the PSTYLEMODE. If it is 0 then use the command CONVERTPSTYLES to convert it from named styles to color. After that, you can assign the color style.
0 Likes
Message 9 of 9

Anonymous
Not applicable
Thanks for all your efforts Mike ! I actually did get my code to work once, not sure why. It happened after I did a couple layout switches but havent been able to reproduce it. If this function requires one to jump through hoops, walk on hot coals, chant in latin, and wave a dead chicken over the head, then I think it may not be worth the trouble. I will take your other suggestions and get back to you soon. Thanks again for all your time. -- Perry Leets Inovec Optimization and Control Systems Eugene, Oregon
0 Likes