assigning colours to polylines

Discussion in 'AutoCAD' started by caderudite, Feb 16, 2005.

  1. caderudite

    caderudite Guest

    hello there,

    I am working on contours which have to be selcted and assign colour using value of Z

    if Z value is 10, 20, 30 or any number which has zero before the decimal point assign colour GREEN

    if Z value can be 11, 12, 13, 48 or any number i mean if there are two numbers (no zero) before the decimal point assign colour YELLOW

    if Z values is 11.250 or 10.550 or anything which has numbers after the decimal point assign colour RED

    I have a large area of contours to be covered

    could anyone please find or have a routine

    I realised assoc38 is the Z value

    Thanks heaps
     
    caderudite, Feb 16, 2005
    #1
  2. caderudite

    Joe Burke Guest

    Seems like a fairly simple test.

    Code:
    ;; argument: a number
    (defun TestNumber ( num )
    (cond
    ((= 0 (rem num 10)) ; -120.0
    (print "Green"))
    ((= 0 (rem num 1)) ; -123.0
    (print "Yellow"))
    (T (print "Red")) ; -123.45
    )
    (princ)
    )
    
    Joe Burke
     
    Joe Burke, Feb 16, 2005
    #2
  3. caderudite

    caderudite Guest

    thanks Joe Burke,
    But i am naive at writing lisp programmes, I don't know how to operate it i mean what is the command to activate it. Could you please give me the full programme.
    thanks a lot
     
    caderudite, Feb 17, 2005
    #3
  4. caderudite

    Joe Burke Guest

    I don't think I'd be helping you if I wrote the program for you. Maybe so in the
    short term, but not in the long run.

    The rest of the program is fairly simple. Basically create a selection set of
    lwplines. Then process each one with code built around a modified version of what I
    posted yesterday. Which might look something like this.

    ;; vobj is the ename of a lwpline converted to a vla-object
    ;; (setq vobj (vlax-ename->vla-object ename)).
    ;; Elevation is the same as the value associated
    ;; with DXF code 38.
    (setq elev (vlax-get vobj 'Elevation))
    (cond
    ((= 0 (rem elev 10)) ; -120.0
    (vlax-put vobj 'Color acGreen))
    ((= 0 (rem elev 1)) ; -123.0
    (vlax-put vobj 'Color acYellow))
    (T (vlax-put vobj 'Color acRed)) ; -123.45
    ) ;end cond

    You don't have to be a programmer to learn how to process objects in a selection set.
    The code structure and the functions used are essentially the same. There are many
    examples of how that's done here.

    What differs is the part above. What are you trying to do to the objects in question.
    And in this case, how to distinguish one pline from another based on its Elevation
    value. That part might be tricky. For instance, you might not know about the rem
    (remainder) function. Those are the kinds of questions you should be asking here.

    I'd be happy to help more if you are willing to give it a try.

    Or maybe someone will take pity and write if for you. If so, that's their business.
    But wouldn't you rather do it yourself?

    Regards
    Joe Burke
     
    Joe Burke, Feb 17, 2005
    #4
  5. caderudite

    caderudite Guest

    thanks i will try and see how i go
     
    caderudite, Feb 17, 2005
    #5
  6. caderudite

    Joe Burke Guest

    Good.

    Don't be bashful about posting code which doesn't work. All we want to see is an
    attempt at learning how to do it. Given that, you'll find many people here more than
    willing to help.

    IOW, join the forum, rather than viewing it as a source free code. Along those lines,
    may I suggest, change your screen name to your real name. Using "caderudite" here
    makes you look a bit silly within context. And some folks in this NG ignore people
    who hide behind false names, for good reasons.

    No offense intended.

    Regards
    Joe Burke
     
    Joe Burke, Feb 18, 2005
    #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.