Changing string to acLineWeight

Discussion in 'AutoCAD' started by Nathan Guill, Dec 2, 2004.

  1. Nathan Guill

    Nathan Guill Guest

    I have written a code that changes the layer depending on what command is
    being performed (i.e. Text command changed to Text layer, Hatch command
    changes to Hatch Layer, etc.). This code also insures that the layer exists
    prior to changing the layer. I am now modifying this code to connect to an
    access database to get the settings for this layer. My problem is that the
    color and lineweight information is passed back as strings. I need to know
    how to convert these to the acColor and acLineWeight variables (i.e. how to
    strip the " from the string). Any help would be appreciated.
     
    Nathan Guill, Dec 2, 2004
    #1
  2. Nathan Guill

    Nathan Guill Guest

    I tried to use these functions, but they didn't work. As an example, when I
    lookup the value in the access database for the Hatch layer, the linetype is
    returned as "AcLnWt009". When I perform a VAL("AcLnWt009"), I get 0. This
    should be 9. When using the other conversion functions (CDBL, CSNG, etc.),
    I just get a type mismatch error.

    But looking at this, I think I am going to revise my database to store the
    numeric value of the AcLineWeight instead of the name. This would then
    work. Thanks for the help.
     
    Nathan Guill, Dec 2, 2004
    #2
  3. One "simple way" would be to do something like this:

    Suppose you have your valued stored as AcLn = "AcLnWt009"

    dim SLW as string
    dim VLW as integer

    SLW =mid(AcLn$,7,len(AcLn$))

    Select case SLW
    case "000" to "211"
    VLW = Cint(SLW)
    case = "ByBlock"
    VLW = -2
    case = "ByLayer"
    VLW = -1
    case = "ByLwDefault"
    VLW = -3
    end Select
     
    Jorge Jimenez, Dec 2, 2004
    #3
  4. Nathan Guill

    wivory Guest

    I don't know if I'm too late to stop you revising your database, but you could do the following:
    Code:
    Eval "ThisDrawing.ActiveLayer.Lineweight =" & MyLineWeight
    
    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Dec 3, 2004
    #4
  5. As long as he uses VBA
    cause Eval( ) is not in VB
     
    Jorge Jimenez, Dec 3, 2004
    #5
  6. Nathan Guill

    Nathan Guill Guest

    I'll try to keep this in mind in the future. I already changed my database.
    Thanks for the help.

     
    Nathan Guill, Dec 3, 2004
    #6
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.