Block information collection

Discussion in 'AutoCAD' started by amjarch, Sep 20, 2004.

  1. amjarch

    amjarch Guest

    Hello all,

    I have a working routine in Lisp that creates a door (based on a few variables) in any wall, trims the wall and makes a block of the door...hooray for me ;) Now, what I would like to do is create another routine that scans the drawing for these door blocks created with this routine, select one of them form a list and insert it.

    When the door is created I am augmenting the given block name with "_xx" so that when I tblsearch in this new routine I assume I could use some wildcard or something to retrieve the list of blocks with this extra bit on the end. (comments on the viability of that concept are more than welcome)

    The real question, however, is once I get the right block how do I extract the overall width of the block so I know how far to trim the wall it will be inserted into? When the door is made and stored as a block the outside of jamb to outside of jamb distance is always in the X plane. What is the most effective way to get the overall X dimension of the saved block?

    I have a feeling it may be inserting the block, entget, entlast, and then some assoc extraction. I just can’t figure what code it might be. I have looked at the dxf code stuff but it doesn't seem to help me.

    Also, I thought of making an attribute in the block that would hold this information that then could be extracted and used. I would rather not do this if I don't have to though.

    Any help would be greatly appreciated. The code is below.

    Thanks,
    Drew Jones

    ;------------------------
    ; INSERT DOORS
    ;------------------------
    (defun c:jdoor (/ clayer os-mode 0-mode frstln ent pnt1 pnt3 pnt3 wid1 wid2 opn1 opn2 opn3 dwid blknm)
    (setq c-layer (getvar "clayer")
    os-mode (getvar "osmode")
    o-mode (getvar "orthomode")
    )
    (setvar "coords" 2)
    (if (not (tblsearch "layer" "A-DO-SWG"))
    (command "layer" "m" "A-DO-SWG" "c" "27" "" "")
    )
    (if (not (tblsearch "layer" "A-DO"))
    (command "layer" "m" "A-DO" "c" "5" "" "")
    )
    (setq frstln (entget(car(nentsel "\nSelect swing side of wall to insert door into:")))
    ent (cdr(assoc -1 frstln))
    )
    (setvar "clayer" (cdr(assoc 8 frstln)))
    (setvar "osmode" 32) ; this is the only osmode that works with otrack point selection
    (setvar "orthomode" 1)
    (command "._ucs" "_ob" ent)
    (setq pnt1 (getpoint "\nHinge point location:")
    pnt2 (getpoint pnt1 "\nDirection of swing?:")
    pnt3 (getpoint pnt1 "\nDirection of opening?:")
    )
    (setvar "osmode" 128)
    (setq wid1 (getdist pnt1 "\nWall thickness \(snap or input\)")
    wid2 (rtos wid1 4 8)
    )
    (setvar "osmode" 0)
    (setq opn1 (getdist "\nOpening size \(3'-0\" default\):")
    opn1 (if (= nil opn1) 36 opn1)
    opn2 (rtos opn1 4 8)
    opn3 (rtos (+ opn1 2) 4 8)
    dwid "1 1/2\""
    )
    (command "._ucs" "_3" pnt1 pnt2 pnt3)
    (command "._ucs" "_z" "270")
    (command "._zoom" "_w" (strcat "40," (rtos (+ opn1 40) 4 8)) (strcat "-" (rtos (+ opn1 40) 4 8) ",-" (rtos (+ wid1 40) 4 8)))
    (command "._line" "2,0" (strcat "2," "-" wid2) "") ;wall trim line
    (command "._line" (strcat "-" opn3 ",-" wid2) (strcat "-" opn3 ",0") "") ;wall trim line
    (command "._trim" "" "0,0" (strcat "0,-" wid2) "")
    (command "layer" "s" "A-DO" "")
    (command "_.rectang" "0,0" (strcat "@-" dwid "," opn2)) ;door
    (command "_.rectang" "0,0" (strcat "@2,-" wid2)) ;hinge jamb
    (command "_.rectang" (strcat "-" opn3 ",0") (strcat "@2" ",-" wid2)) ;strike side jamb
    (command "layer" "s" "A-DO-SWG" "")
    (command "._arc" "_c" "0,0" (strcat "0," opn2) (strcat "-" opn2 ",0")) ;door swing
    (setq blknm (getstring "\nDoor block name:"))
    (while (tblsearch "block" (strcat blknm "_xx")) (setq blknm (getstring "\nName already inuse, choose another one:"))) ;block name loop
    (command "._block" (strcat blknm "_xx") "0,0" "0,1" "0,-1" (strcat "-" opn2 ",-1") (strcat "-" opn2 ",1") "") ;block creation
    (setvar "clayer" "0")
    (command "._insert" (strcat blknm "_xx") "0,0" "1" "1" "") ;block insertion
    (setvar "clayer" c-layer)
    (setvar "osmode" os-mode)
    (setvar "orthomode" omode)
    (command "_.ucs" "" )
    (princ)
    )
     
    amjarch, Sep 20, 2004
    #1
  2. amjarch

    dblaha Guest

    Have you considered making the width of the door part of the block name (ie: *_36_xx)?

    Dave
     
    dblaha, Sep 20, 2004
    #2
  3. amjarch

    Daron Denton Guest

    You might try something like using the door *type* in the name
    - DOORSS..... = single swing
    - DOORDS.... = double swing
    - etc.

    add the specifics of the door to the inserted block in xdata. this will give
    you a much more flexible format for storing information. if you tie all
    needed information to the name, what happens if you decide to add more data?
    using xdata will allow you to this without disrupt your
    naming/inserting/search & extract functions.


    --
    Daron
    We are human beings,
    not human doings.



    variables) in any wall, trims the wall and makes a block of the
    door...hooray for me ;) Now, what I would like to do is create another
    routine that scans the drawing for these door blocks created with this
    routine, select one of them form a list and insert it.
    so that when I tblsearch in this new routine I assume I could use some
    wildcard or something to retrieve the list of blocks with this extra bit on
    the end. (comments on the viability of that concept are more than welcome)
    the overall width of the block so I know how far to trim the wall it will be
    inserted into? When the door is made and stored as a block the outside of
    jamb to outside of jamb distance is always in the X plane. What is the
    most effective way to get the overall X dimension of the saved block?
    some assoc extraction. I just can't figure what code it might be. I have
    looked at the dxf code stuff but it doesn't seem to help me.
    information that then could be extracted and used. I would rather not do
    this if I don't have to though.
    wid2 opn1 opn2 opn3 dwid blknm)
    (rtos (+ opn1 40) 4 8) ",-" (rtos (+ wid1 40) 4 8)))
    "\nName already inuse, choose another one:"))) ;block name loop
    opn2 ",-1") (strcat "-" opn2 ",1") "") ;block creation
     
    Daron Denton, Sep 20, 2004
    #3
  4. amjarch

    amjarch Guest

    Dave, Daron,

    Thanks for your replies. I think that the xdata, while being uncharted territory for me, is the way to run. I have found what i need to find in the help file to get me started, but I will be back if I need a little more guidance. Are there undocumented hang-ups that i might be made aware of before I get started?

    Thanks again,
    Drew
     
    amjarch, Sep 21, 2004
    #4
  5. amjarch

    Daron Denton Guest

    the help files are pretty good if you want to figure it out yourself. if you
    want some code to read / write xdata, i can help you there too.

    a few suggestions... if you have an acad.lsp (for example) that loads other
    functionality, i suggest putting your read / write xdata functions here. you
    can use the same code for more than just your doors, and have your door
    functions call the xdata functions.

    also, if you have express tools installed, look under *Tools / Xdata Attach
    & List Entity Xdata*. this will give you an idea of how you can add xdata to
    just about anything. you may not need that much detail, but you'll get the
    idea.

    i'm not here too often, but if you get stuck & want off-line help, e me at
    cadadmin at. dfdch dot. com.

    --
    Daron
    We are human beings,
    not human doings.



    territory for me, is the way to run. I have found what i need to find in
    the help file to get me started, but I will be back if I need a little more
    guidance. Are there undocumented hang-ups that i might be made aware of
    before I get started?
     
    Daron Denton, Sep 21, 2004
    #5
  6. amjarch

    amjarch Guest

    Daron,

    Thanks for extending a helping hand. The hardest part of all this is getting started properly. If you could impart to me the general structure of an xdata read/write code that would be very cool. I will try my own hand at this later today or later this week. If I get stuck I will drop you a line.

    Thanks,
    Drew
     
    amjarch, Sep 21, 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.