cant set stylesheet

Discussion in 'AutoCAD' started by perry, Feb 3, 2004.

  1. perry

    perry Guest

    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, Feb 3, 2004
    #1
  2. 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
     
    Mike Tuersley, Feb 3, 2004
    #2
  3. perry

    perry Guest

    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, Feb 3, 2004
    #3
  4. perry

    perry Guest

    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, Feb 3, 2004
    #4
  5. 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
     
    Mike Tuersley, Feb 3, 2004
    #5
  6. 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
     
    Mike Tuersley, Feb 3, 2004
    #6
  7. perry

    perry Guest

    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, Feb 3, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.