if/Cond angle

Discussion in 'AutoCAD' started by jvellek, Mar 23, 2005.

  1. jvellek

    jvellek Guest

    I am trying to elevate two angles to evaluate whether the block insertion x, y or both scales needs to be set to 1 or -1. I am having a very difficult time trying to setup the if or conditional statements to evaluate all the conditions that are possible. This routine inserts a door block into a wall so it has to determine which side of the wall it needs to go on and so that it is also pointed in the proper direction parallel to the wall. Can anyone offer suggestions?
     
    jvellek, Mar 23, 2005
    #1
  2. If your wall is two parallel lines, here's what I've done (in Screen Menu
    format):

    [...layer and osnap and other miscellaneous stuff first, including setting
    of variables drsize (door size -- width in inches) and drname (door name,
    varying for swinging, folding, pocket, etc. -- this is the one for a single
    swinging door)....]

    (setq wallline (entsel "HINGEPOINT ON WALL: ")) \+
    (setq hinge (osnap (cadr wallline) "NEA")) +
    (setq rot (angle hinge (osnap (getpoint +
    "DIRECTION TO OTHER SIDE OF DOOR: ") "NEA"))) \+
    SNAP R !hinge !rot ORTHO ON +
    (setq dir (getangle hinge "OPENING DIRECTION: ")) \+
    [[...calculates some points, breaks wall lines, and draws edges of the
    opening...]]
    (setq test (- dir rot)) +
    (if (or (and (minusp test) (< (abs test) pi)) +
    (and (not (minusp test)) (> (abs test) pi))) (+
    setq yscale (- 0 drsize)) (setq yscale drsize)) +
    [[...another layer setting for the door layer...]]
    -INSERT !drname !hinge !drsize !yscale !dir
    [[...sets Snap rotation back, etc., etc....]]

    This asks for a hingepoint on the wall [line], a direction to the strike
    side, and a swing direction (with ortho on and snap rotated to align with
    the wall). The part that may be of most use to you is the (setq test....
    part near the end, but you need to see the earlier stuff to know how the
    "rot" and "dir" variables are set: "rot" is the rotation of the wall, the
    direction from the hinge to the strike; "dir" is the direction the door
    swings, perpendicular to "rot". Depending on their relationship, it sets
    the y scale of the block either positive or negative. The block is unit
    size, so its scale is the door width, but the same procedure could be used
    to calculate whether to set yours to 1 or -1.

    Maybe the determination is a little clearer this way, which you might use in
    a defun'd command:

    (setq test (- dir rot))
    (if
    (or
    (and
    (minusp test)
    (< (abs test) pi))
    (and
    (not (minusp test))
    (> (abs test) pi)))
    (setq yscale (- 0 drsize))
    (setq yscale drsize)) +

    Kent Cooper


    ...
     
    Kent Cooper, AIA, Mar 23, 2005
    #2
  3. jvellek

    jvellek Guest

    My routine is similar but this still doesn't seem to work in all conditions.

    This is the portion of the code I have been playing with:
    ;jamb_ang is the angle of the jamb
    ;opening_ang is the door opening from the hingept to the opposite jamb
    ;sclx is the x scale factor
    ;scly is the y scale factor
    ;;;it fails when openang=180
    ;;insertang=90
    ;;rotang=90
    ;;sclx=1
    ;;scly=-1
    ;;SCLY Should be 1


    (setq insertang (rtd jamb_ang))
    (setq openang (rtd opening_ang))
    (setq rotang (abs (- insertang openang)))
    (setq SCLX 1)
    (setq test (- insertang openang))
    (if
    (or
    (and (minusp test)(< (abs test) pi))

    (and (not (minusp test))(> (abs test) pi))
    )
    (setq SCLy sclx)
    (setq SCLy (- 0 sclx)))
    (command "_.insert" blknam 1st_pt SCLX SCLY insertang)



    What am I missing?
     
    jvellek, Mar 23, 2005
    #3
  4. jvellek

    jvellek Guest

    Nevermind - I think I got it:

    (setq blknam "dr3690")
    (setq insertang (rtd jamb_ang))
    (setq openang (rtd opening_ang))
    (setq rotang (abs (- insertang openang)))
    (setq SCLX 1)
    (setq test (- openang rotang))
    (if
    (or
    (and (minusp test)(< (abs test) pi))
    (and (not (minusp test))(> (abs test) pi))
    )
    (setq SCLy -1)
    (setq SCLy 1))
    (command "_.insert" blknam 1st_pt SCLX SCLY insertang)




    Thanks for your help
     
    jvellek, Mar 23, 2005
    #4
  5. jvellek

    jvellek Guest

    I spoke too soon - it still fails in some conditions - arghhhhh
     
    jvellek, Mar 23, 2005
    #5
  6. jvellek

    jvellek Guest

    I'm a dummy-forgot to convert pi to degrees - it all works fine now
     
    jvellek, Mar 23, 2005
    #6
  7. jvellek

    Joe Burke Guest

    A thought or two based on many hours thinking about how to put a 2D door into a 2D
    wall.

    Personally I think it's a mistake trying to use a scaled block, for a couple reasons.

    If you want the door to be represented as a rectangle rather than a line (I do) then
    the thickness of the door is scale dependant. Which makes no sense.

    On top of that, the block in question must be drawn on various hard-coded layers.
    Assuming you want the jambs on a Wall layer, the door on a Floor layer, and the door
    head on a Ceiling layer. The block approach offers zero flexibility in terms of
    various layer naming schemes.

    IMO, it's worth the effort to draw the door on-the-fly rather than use a scaled
    block. You can group the new objects so they behave similar to a block in terms of
    copy. And you can tailor the program so various layer naming schemes are allowed.

    What I'm suggesting isn't theory. I have working code for various door types.

    Just my two cents...
    Joe Burke
     
    Joe Burke, Mar 24, 2005
    #7
  8. jvellek

    James Allen Guest

    [Off Topic, sorta]

    Hi Joe,

    From what people have been saying about the new dynamic blocks in a2k6, you
    may be rethinking this in the future.

    I haven't paid too much attention specifically to doors in my work, but it
    sounds like you could have *a* door block that you could make fit any
    opening without changing the panel thickness.

    The block vs layering schemes issue has been a source of serious frustration
    for me. I'm not as sure that the dynamic blocks will help on this one, but
    I'm hoping. It sounds like you can save different view states with each
    block, so maybe the different view states could be tied to layer visibility.
    For your example, have 3 views; Jamb, Panel, and Head. Then for a default
    insertion tie Jamb to Wall layer, Panel to Floor layer, and Head to Ceiling
    layer. But maybe you insert another one for demolition, so for this one you
    tie Jamb to DWall, Panel to DFloor, and Head to DCeiling, all using the same
    block.

    I'll be pleasantly surprised if all this (or equivalent) can be accomplished
    with these new blocks; particularly some accomodation for layer scheming.
     
    James Allen, Mar 24, 2005
    #8
  9. I agree on some of the shortcomings of the door-as-scaled-block approach,
    but it brings with it some opportunities that your approach does not allow.
    Two examples:

    1. I have a menu item to flip a door so it swings (or folds or slides) from
    the other side of the opening. Because the door is a block, the routine can
    determine from its insertion point, scales (including whether the Y scale
    factor is positive or negative) and rotation angle, the location and
    direction of the mirror line to flip it by. I just invoke the FlipDoor
    item, pick the door, and it's instantly reversed.

    2. I have a menu item to put door numbers in. I like to write the number
    alongside the leaf of the door, which takes less space (and a hair less
    memory) in the drawing, and is less likely to get in the way of other
    information like dimensions, than the common number-in-a-circle approach. I
    invoke that menu item, pick anywhere on the door block, give it the number,
    and the routine instantly sets the layer, calculates the position, size and
    direction of the text based on the block information and drawing scale, and
    writes it in, perfectly positioned. It even knows from the block name
    whether it's a 90-degree or a 45-degree swinging door, or a folding or
    sliding or pocket door, and calculates accordingly.

    I find a line for the door perfectly adequate at 1/8" scale, with a heavier
    line weight for the door than the swing. Occasionally I'll feel a need for
    a rectangle at larger scales, and I can substitute a block definition with
    that built in for the right thickness on a 36" door (which most doors are
    these days, with accessibility requirements). Yeah, it comes out a little
    thinner on narrower doors, but not so's you notice much, most of the time.

    As to the "flexibility" for layer naming schemes, if you're working with a
    CAD standard, that should all be covered, and I wouldn't think you'd want
    people to have flexibility. And if you want it different, once you've got a
    block definition in the drawing, renaming a layer, or assigning a different
    linetype, or LAYMRG, will take care of it easily enough, for the entire
    drawing all at one shot. That seems like a lot less extra work than the
    extra work involved in drawing doors on the fly, and grouping them, and
    copying them around, when you can do them much more quickly with a routine.
     
    Kent Cooper, AIA, Mar 24, 2005
    #9
  10. Agree, I end up doing something like these on my abandoned door and window
    installation routines.
     
    Luis Esquivel, Mar 24, 2005
    #10
  11. jvellek

    Joe Burke Guest

    Hi James,

    No doubt I'll need to rethink what I said about door insertion programs, once the
    dynamic blocks in 2006 become standard fare.

    I haven't seen 2006 in the flesh yet. Agreed, I'm not sure what the implications may
    be until I understand how it works.

    Regards, and good from you on this point.
    Joe


     
    Joe Burke, Mar 24, 2005
    #11
  12. jvellek

    Joe Burke Guest

    Hi Kent,

    You don't need the door as a block to flip its swing one way or the other. A group
    will suffice, or simply a mirrored selection set.

    CAD standards are good as far as they go. But it's not reasonable for me to assume
    everyone who might use my door programs, is using the same set of standards. I need
    to allow for that. I do so by rather elaborate checking scheme. The data gathered
    from user input is stored in an xrecord, which is used when the programs are called
    again.

    Regards
    Joe Burke
     
    Joe Burke, Mar 25, 2005
    #12
  13. But with a group or selection set, YOU have to do a lot more -- tell it
    you're done picking things, and establish the mirror line for flipping it.
    If you want the opening to stay in the same place, and hinge (or fold or
    slide) the door from the other side of it, you have to use a mid-of-two kind
    of thing, because the mirror line will likely be in the middle of nowhere,
    and if the wall isn't orthogonal, you can't use ortho for the mirror-line
    direction, but need to go perpendicular to a wall line or something, and you
    need to give it the "yes" to delete the original. With my door as a block,
    all I do is pick it, and all that is taken care of for me, instantly,
    because the routine can figure it all out from the insertion point and scale
    factors and rotation angle of the block, none of which are available with a
    group, and the other things (like completing the selection set, and
    affirming deletion of the original) are all built in.

    I also have (in addition to the door numbering thing I listed before)
    routines to change between 90-degree and 45-degree door swing blocks (the
    same routine goes either way), and to change a 45-degree one to a demolition
    layer and put in a new 90-degree one, for replacing a door in an existing
    frame. Those take advantage of the fact that blocks have names, in addition
    to using the insertion/scale/rotation information. You can't do either of
    those anywhere near as quickly with on-the-fly doors, grouped or otherwise.
    (They also ensure it happens on the right layer, which you would otherwise
    have to be conscious of for yourself.)

    While doing it this way may have "drawbacks" to some slight degree (like the
    lack of thickness in the door), it really does also have substantial
    advantages.
     
    Kent Cooper, AIA, Mar 25, 2005
    #13
  14. jvellek

    jvellek Guest

    well - I can't believe I started such a thread. I do not scale my blocks but basically have them mirrored. I too hate the scale one block idea as they never look right and it is hard to get a block count (no of demo doors vs extg). I have acutally created a variety (400+) blocks to accommodate all the door conditions. I truly hope the new parametric blocks will eliminate a lot of this for me. Thanks for all the responses.
     
    jvellek, Mar 25, 2005
    #14
  15. jvellek

    Joe Burke Guest

    Hi Kent,

    Agreed, the way I do it ain't easy. It takes a lot of code.

    The mirror line is established by determining the midpoint of each jamb line.

    Of course, whatever works best given your situation... :)

    Mine is I'm working as a consultant to architects who will not accept the door as a
    line idea. I have no choice in the matter. Door must be a rectangle. Plus one of my
    clients is anal to the point of worrying about the difference between an 1 3/4"
    versus a 1 3/8" door. I don't agree with that. I would draw all 1 1/2" thick. But I'm
    certainly not going to debate that point with a client. Just give them what they
    want. Drawing on-the-fly lets me do that with a question about door thickness.

    Door at 90 degrees or 45 is just another question the user has to deal with.

    I make a group to deal with the odd case where the user might want to copy a door,
    modify it, and then manually place in a wall. Given a decent door insert program,
    there's few cases where you'd want to do that.

    One advantage with drawing on-the-fly is it doesn't depend on door blocks being
    present in a file. As I understand, you probably only need a few. And I know you can
    create those blocks if they don't exist. On the other hand, see jvellek's comment
    about 400+ blocks. Not a good idea.

    If you'd like to kick this around a bit more, I'd be interested in how many clicks
    does it take to insert a door with your code? When I started, and didn't know much
    about programming, it took four. Not much later I got it down to three. Then I
    screwed it down to two, which was a mistake because the code was less reliable in odd
    situations. Eventually I rewrote from scratch using Active X, vlisp, and three
    clicks. Now it works very well.

    I mention this because it's an example of fixation on fewest number of clicks getting
    out-of-hand. What I learned is a click is a cheap price to pay for reliability. At
    least given my level of programming experience.

    I think Luis got it down to one click at a wall corner in his DrafTeam suite. What
    say you Luis? If I'm right about that, was it a good idea given the balance we seek
    between code complexity, reliability, and ease of use?

    BTW, I'll post my code if anyone would like to try it.

    Regarding layer naming schemes, it deals with renovation and new construction work
    based on a user supplied name for the Wall layer, entered once per drawing. The Wall
    layer name can be one of these: "A-Wall", "A-WALL", "A-Wall-N", "A-WALL-N",
    "A-Wall-New" or "A-WALL-NEW". Similar layer names are created as needed. For
    instance, "A-Flor-N" if the user inputs "A-Wall-N".

    And a rant, if you don't mind. It's totally ridiculous the folks studying layer
    naming standards (you know of whom I speak) don't make their work freely available to
    all. Instead they screw their heads on backwards and think of it as a money making
    proposition. Which in the end means there are no layer naming standards and the
    greedy (expletive deleted) failed miserably at what they intended to do. In turn,
    everyone in the construction industry suffers.

    Regards to all,
    Joe Burke
     
    Joe Burke, Mar 26, 2005
    #15
  16. Hola Jose,

    Yes, what I wrote about installing doors and windows use a single click, and the base code for this is just about 160 lines, everything basically is done with active-x, the doors and windows are blocks but they are built with real dimensions, the last part I did and never make it to the public, was the ability to do installations per type EXISTING, DEMO and NEW.

    In example if an existing door was installed and then later needed to be changes to new or demo, the command will make the change by simple clicking on a modify button.

    Also I introduce the use of the objectDCL dialogs, to try to make the utilities more professional.

    It was a real fun, to write that code.

    LE.
     
    Luis Esquivel, Mar 26, 2005
    #16
  17. jvellek

    Joe Burke Guest

    Hola Luis,

    Sorry I can't reply in Spanish. Languages were the one thing I could never get my
    head around in school.

    As I recall, your one click door insert thing swung the door to the side of a
    selected wall corner point. Then if you wanted to flip the swing to the other side, a
    dialog box was presented which allowed that option.

    If I'm right so far, it's one click thing when the door swings as it usually does,
    into the room. But not when it doesn't. I'm not arguing here. Your logic makes sense,
    if I understand it correctly.

    What I don't know or recall is how you made it smart enough to understand which wall
    the door should be inserted on, given only a corner point.

    What I do is ask the user to pick the swing side wall line first. Then the opposite
    side wall line. Then the corner point and enter an offset distance from corner.
    Typically a default last-used distance. Not exactly economical in terms of clicks,
    but highly reliable codewise in terms of doing what the user expects on the first
    pass without a dialog.

    I learned a lot while working on this. Your help and guidance is appreciated as usual
    my friend.

    Regards
    Joe
     
    Joe Burke, Mar 27, 2005
    #17
  18. FWIW, I demonstrated the concept behind a one-click
    door insertion prrogram here, many moons ago (using
    the distance from the corner of a room as a parameter
    in deciding which side of the opening the door is hinged
    on).

    If you're inserting into a double-line wall then you just
    click the side that the door is hinged on (or swings into
    as you say).

    It's really not difficult to do, and I'll be happy to argue
    about it with you if you want :)
     
    Tony Tanzillo, Mar 27, 2005
    #18
  19. ...
    .....
    You misunderstood my door-flipping operation. I'm talking about (in the
    case of a swinging door) swinging to the same side of the wall, but
    switching it to swing from the other jamb. (It also works for changing a
    folding or pocket door's opening direction.) The mirror line would be in
    the middle of the opening, so there wouldn't be anything to pick the
    midpoint of, unless you have doorhead lines for a reflected ceiling plan.
    I have them in a folder in the support file search path, so they don't need
    to be in the drawing (but they are once I've used them once). I have nine:
    a 90-degree swinging door, a 45-degree swinging, double-door versions of
    both of those, a folding, a bi-folding, a pocket, and two- and three-leaf
    sliders.
    I have Screen Menu setup picks to do, to tell it how thick the wall is, how
    wide the door is (per leaf for some of them), and to choose a type. Then I
    pick **GO**, and it's three picks from there: the hingepoint on a wall line
    (it uses NEA osnap so you don't have to be smack on), any place along the
    same line in the direction toward the opposite jamb (only to establish the
    direction), and the swinging direction. As long as I keep using the same
    size and type of door, I can just keep picking **GO** as many times as I
    want, so I only have to do the other input for the first one.
    Mine finds the Layer of the wall line, and sets that for drawing the lines
    for the jambs of the opening, so the user doesn't have to deal with that.
    It also has an option in the Screen Menu preliminaries if you want to tell
    it to put the door itself on a Layer other than the drawing standard (such
    as a demolition or future-work layer).

    I agree with your "rant" -- but there are sources of information out there.
    We've found some, and made our own refinements. Check out, for example,
    http://www.slcc.edu/tech/techsp/arch/courses/ARCH2510/CAD_Stds/cover.html
     
    Kent Cooper, AIA, Mar 28, 2005
    #19
  20. jvellek

    Joe Burke Guest

    Hi Luis,

    Thanks for the graphic. :)

    Apparently I forgot how your program worked. I thought the single click was at a
    corner of a room, rather than along a wall line.

    So my question becomes, what method is used to find the opposite wall line? Which in
    turn determines wall thickness and I assume jamb points on the wall opposite from the
    click point. This might be what Tony is referring to?

    That issue is what I tried to deal with when I had a two click interface. How that
    interface worked isn't relevant to the question. Suffice it to say, the second click
    was not on the opposite wall line.

    The method I used to find the opposite wall was a fence selection from the point
    picked perpendicular to the angle of the wall line selected. Looking in both
    directions, given a limited distance, for the closest line on the same layer as the
    wall line initially picked. Eventually I found there was a fatal flaw with that
    method. When the wall lines were not orthogonal, though still parallel, the selection
    point returned by ssnamex (as I recall) wasn't exactly where I expected. That caused
    parts of the door to be drawn at slightly the wrong angle. It looked OK on paper, but
    it wasn't mathematically correct.

    At that point I gave up and went back to picking both wall lines and a click in the
    corner.

    Regards
    Joe
     
    Joe Burke, Mar 29, 2005
    #20
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.