have a quick look guys and gals

Discussion in 'AutoCAD' started by mnash, Jun 4, 2004.

  1. mnash

    mnash Guest

    I have a single line test entity with contents being
    "L5x3x1/4"

    Based on that string of text, I want to run a specific series of commands. How do I pull that information to a variable?

    I'm boggled
     
    mnash, Jun 4, 2004
    #1
  2. mnash

    T.Willey Guest

    (setq tx1 "L5x3x1/4")

    Tim
     
    T.Willey, Jun 4, 2004
    #2
  3. Assuming L5x3x1/4 -
    5 = length always whole number
    3 = width always whole number
    1/4 = depth can be whole and or fractions

    (setq Plen (getint "\nInput Part Length ? "))
    (setq Pwid (getint "\nInput Part Width ? "))
    (setq Pdep (getreal "\nInput Part Depth ? "))
    (setq Psiz (strcat "L" (itoa Plen) "x" (itoa Pwid) "x" (rtos Pdep 5 3)))

    Note - you will have to play with "getreal" input and "rtos" output to match
    block names

    How do I pull that information to a variable?
     
    Alan Henderson @ A'cad Solutions, Jun 4, 2004
    #3
  4. I think what you're looking for is a way to select the pre-existing text
    entity, and have the appropriate block inserted (and whatever other commands
    you have in mind). So the (setq) thing you need would have to EXTRACT the
    text content from that text entity that you select, something like [in
    macro-type format, and NOT TESTED]:

    (setq angletext (assoc <whatever-it-is-for-text-content-I-didn't-look>
    (entget (car (entsel "Select designation: "))))) \

    Then, later on, something like:

    (if (= angletext "L5x3x1/4") <...do all the stuff you want to do...>

    Actually, I'd suggest, in case it's possible that the x's in the designation
    might be upper OR lower case, that you do it this way (assuming the above
    shot-from-the-hip actually works right otherwise):

    (setq angletext (strcase (assoc <whatever> (entget (car (entsel "Select
    designation: ")))))) \

    to force it to convert it to upper case. Then, later on, something like:

    (if (= angletext "L5X3X1/4") <...do all the stuff you want to do...>

    Kent Cooper, AIA


    How do I pull that information to a variable?
     
    Kent Cooper, AIA, Jun 4, 2004
    #4
  5. mnash

    mnash Guest

    I think we're on the right track now
    Yes I need to utilize the pre-existing text of the single line text entity. That entity is what I want to equal "STK" so that if "STK" equals "L5x3x1/4" then <do whatever needs to be done> If the "STK equals "L6x2x1/4" then <do another bunch of steps that needs to be done.
     
    mnash, Jun 4, 2004
    #5
  6. mnash

    T.Willey Guest

    Then if you have the text just grab (assoc 1 <>) of Kent's statement. That will grab the text of the text object. Then use your "cond" statements.

    Tim
     
    T.Willey, Jun 4, 2004
    #6
  7. mnash

    mnash Guest

    lets try again

    to assign my variable "STK" is it:

    (setq STK (assoc 1)

    ?
     
    mnash, Jun 8, 2004
    #7
  8. mnash

    Paul Turvill Guest

    Is this what you're looking for?

    (setq txt (entget (entsel "\nSelect text: ")))
    (setq STK (cdr (assoc 1 txt)))
    ___
     
    Paul Turvill, Jun 8, 2004
    #8
  9. mnash

    Paul Turvill Guest

    Sorry -- that should be:

    (setq txt (entget (car (entsel "\nSelect text: "))))
    (setq STK (cdr (assoc 1 txt)))
    ___
     
    Paul Turvill, Jun 8, 2004
    #9
  10. mnash

    mnash Guest

    Paul, thats the one.
    Thanks for your help guys, much appreciated

    m
     
    mnash, Jun 14, 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.