Parse ctb file

Discussion in 'AutoCAD' started by michael montagne, Oct 29, 2004.

  1. We are involved with an associated architect and need to pass our
    drawings to them. They would like us to follow their standards. In
    order to avoid forcing our architects to adapt to different colors, I'm
    going to use their layernames but our colors up until the time we hand
    over the drawings. The run a converter to change the colors of each
    layer. All objects are colored bylayer (right?).
    It would be slick if I could have some code to help me match the proper
    color/lineweight combos. Are the ctb file settings accessible via VBA?

    -mjm
     
    michael montagne, Oct 29, 2004
    #1
  2. Have you considered using the Layer Translator?
     
    Frank Oquendo, Oct 29, 2004
    #2
  3. Interesting. Actually use a built-in tool rather than inventing it
    myself. It seems, tho, that the Layer Translator need specific names.
    All I want is to walk the layers and change the colors. That way, I
    don't need to know which layers are in the drawing.

    -mjm
     
    michael montagne, Oct 29, 2004
    #3
  4. How does the CTB file figure into that? Plot styles affect output, not
    content.
     
    Frank Oquendo, Oct 29, 2004
    #4
  5. I want a simple way to map color to lineweight without having to look at
    each individual entry and write it down. I could just ask their CAD
    Manager for a copy of their color settings, but the .ctb file idea is
    much more robust and trustworthy. Trouble is, the exact lineweights
    won't match ours exactly, so I'd either need a fuzz factor or do that
    manually.
     
    michael montagne, Oct 29, 2004
    #5
  6. michael montagne

    John Coon Guest

    Michael,

    what about a simple alternative with a layer script. drag & drop into a
    drawing or link it to a toolbar or menu


    (setq oldlay (getvar "clayer")) -layer s 0
    (setq oldregen (getvar "regenmode"))
    (setvar "regenmode" 0)
    ;****
    ;;;Surfaces
    ;****
    -layer c 7 *-SRF-VIEW,*-SRF-BDR c 6 *SRF-FLT
    -layer c 1 *SRF-RNG1 c 2 *SRF-RNG2 c 3 *SRF-RNG3 c 4 *SRF-RNG4 c 5 *SRF-RNG5
    c 6 *SRF-RNG6 c 7 *SRF-RNG7 c 8 *SRF-RNG8 c 9 *SRF-RNG9 c 10 *SRF-RNG10 c 11
    *SRF-RNG11 c 40 *SRF-RNG12 c 13 *SRF-RNG13 c 43 *SRF-RNG14 c 15 *SRF-RNG15 c
    134 *SRF-RNG16
    -layer c 6 *-CONT-MNR c 4 *-CONT-MJR c 42 *EG-CONT-MNR c 31 *EG-CONT-MJR
    -layer lt hidden *EG-CONT-MJR lt hidden2 *EG-CONT-MNR
    ;****
    ;;;Alignments
    ;****
    -layer c 3 *-STALBL,*-STAPI,*-STAPTS
    ;****
    ;;;Profile
    ;****
    -layer c 5 *-PBASE c 3 *-PEGC c 2 *-PEGCT c 253 *-PVGRID,*-PGRID c 253
    *-PGRIDT c 1 *-PEGL c 40 *-PEGR c 2 *-PEGLT,*-PEGRT
    ;****
    ;;;Pipes
    ;****
    -layer c 7 *-CONPL,CONPR c 6 *FINPL,*FINPR,*PLTXT,*PRTXT
    ;****
    ;;;Cross Sections
    ;****
    -layer c 4 *-PFGC,*-PFGCT
    ;****
    ;;;this sets the layer back
    ;****
    (setvar "clayer" oldlay)
    (setvar "regenmode" oldregen)
    regen
     
    John Coon, Oct 30, 2004
    #6
  7. michael montagne

    GTVic Guest

    As far as I know the CTB files are encoded with a string compression library, possibly using encryption. I think Autodesk wants them to be proprietary.
     
    GTVic, Oct 30, 2004
    #7
  8. michael montagne

    MickyV Guest

    If you have the Express Tools, you could use the Layer Manager. Lets you save the layer state, and can import/export to a file. So you'll need to set it up once, then just import into the drawings. Once it's there, just double click on the settings that you want to use, and it'll update all of the layers according to the way you had it when you saved the settings. And, it'll let you go back and forth between the layer states in the blink of an eye!

    Mick.
     
    MickyV, Oct 31, 2004
    #8
  9. Those are good suggestions but I'm never sure exactly what layers are
    going to be present. I need to visit each layer and change the color to
    what it needs to be I think. No biggie, I just hoped to have a neato
    way to map the colors.

    -mjm
     
    michael montagne, Oct 31, 2004
    #9
  10. michael montagne

    AKS Guest

    Both you and your client plot by color to achieve line weight symbology. You
    have a list of the client's layer names, colors and weights. You have a list of
    your own layer names, colors and weights. Most of your layer names exist
    in the client list because you are following their layer names. However, not
    all of your layer names may exist in the client list. These are the unknown
    layers you mentioned. You do know the weight you use for these unknown
    layers and so you plan to find a matching weight (within a tolerance factor -
    your fuzz) in the client list and then use the corresponding client color for
    that matching weight. Your converted files will plot similar to the client's files
    but they may not have the same screen sense.

    It should be easy -- once you have the mapping tables. That is what you are
    asking for. I would make my own tables as comma delininated text files.
    One for your system and one for the client system. Assuming you cannot
    read the ctb or pc3 files (which I have not checked), you can build VBA
    tools to write most of each table (layer name, color) from sample dwgs of
    each type. Then load the table files into Excel to finish them off. Use Excel
    to write them back out again. How many different weights can there be?
     
    AKS, Oct 31, 2004
    #10
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.