draw line to middle of 2 picked lines then offset that line help...

Discussion in 'AutoCAD' started by akdrafter, Feb 18, 2004.

  1. akdrafter

    akdrafter Guest

    Hello All,

    Here I am again. I have wracked my brain trying to get this to work with out asking for help.....until now. I have basically tried to piece together other lisp routines to get it to work and with little or no tangeble results. In a nut shell:

    (acad 2002)

    ;;;
    pick wall line one(*line, xref *line, block *line)

    pick wall line two(*line, xref *line, block *line)

    draw a line(or not) to the exact middle of those two wall lines

    offset the newly drawn line to a default distance(16) or one entered by the user on the command line

    pick a side(as far as I know, one has to pick a side), however I have seen a double offset that erases the original but don't know how I would incorporate that into the routine to eliminate having to pick a side

    erase line drawn in the middle of wall line one and wall line two(if it was created)
    ;;;

    It's a footing routine. I get drawings from Architects that I have to place a footing centered under the walls. I have a way of doing it now that works, but it is a group of separate routines that I can't get to work as one and do what I listed above. Being self taught and trying to absorb the information I have received here only goes so far.....apparently not far enough **smiles**.

    Any help is appreciated and thanks in advance.

    "Catch" Ya Later,
    AKDRAFTER
     
    akdrafter, Feb 18, 2004
    #1
  2. akdrafter

    Joe Burke Guest

    akdrafter,

    This might help with some of your questions.

    ;; 2/17/2004
    ;; demo - offset both sides and delete source object
    ;; offset method accepts positive or negative distance
    ;; see help regarding the offset method
    (defun c:OffsetDel ( / dist ename vobj )
    (setq dist (getdist "\nEnter offset distance: "))
    (setq ename (car (entsel "\nSelect object to offset: ")))
    (setq vobj (vlax-ename->vla-object ename))
    (if (vlax-method-applicable-p vobj 'Offset)
    (progn
    (vlax-invoke vobj 'Offset dist)
    (vlax-invoke vobj 'Offset (- dist))
    (vlax-invoke vobj 'Delete)
    )
    (princ "\nCannot offset selected object type ")
    )
    (princ)
    ) ;end

    Joe Burke


    for help.....until now. I have basically tried to piece together other lisp routines
    to get it to work and with little or no tangeble results. In a nut shell:
    offset that erases the original but don't know how I would incorporate that into the
    routine to eliminate having to pick a side
    footing centered under the walls. I have a way of doing it now that works, but it is
    a group of separate routines that I can't get to work as one and do what I listed
    above. Being self taught and trying to absorb the information I have received here
    only goes so far.....apparently not far enough **smiles**.
     
    Joe Burke, Feb 18, 2004
    #2
  3. akdrafter

    David Kozina Guest

    One simple possibility you may have overlooked...

    You can easily define/create an mlinestyle with 3 elements equally spaced at
    +0.5, 0, -0.5, for a total width of 1.0

    This can then be used in your drawings, using the 3 possible justifications
    and any number of widths. The middle element of the style will provide you
    with an automatic midline (particularly handy when walls join at a
    non-orthogonal angle. Draw it on a 'no plot' layer, such as defpoints.

    Of course, mlines won't work on curved walls - but as they seem to be in the
    minority on most of the projects I work on, using OFFSET in those cases
    works fairly quickly.

    Just some random comments regarding centered footing placements on plan.
    We have used mlines in this and other ways for years and they work very
    well. And now all the more so, since we discovered recently that mlines
    *also* respect Plotstyles (if you're using .STBs) :)
    YMMV.

    hth,
    David Kozina


    out asking for help.....until now. I have basically tried to piece together
    other lisp routines to get it to work and with little or no tangeble
    results. In a nut shell:
    a double offset that erases the original but don't know how I would
    incorporate that into the routine to eliminate having to pick a side
    place a footing centered under the walls. I have a way of doing it now that
    works, but it is a group of separate routines that I can't get to work as
    one and do what I listed above. Being self taught and trying to absorb the
    information I have received here only goes so far.....apparently not far
    enough **smiles**.
     
    David Kozina, Feb 18, 2004
    #3
  4. akdrafter

    btlsp Guest

    btlsp, Feb 18, 2004
    #4
  5. akdrafter

    akdrafter Guest

    Hello All,

    Here is the code I have so far. It seems to work if you enter in the footing size every time, but has no memory. What it is doing is taking the value entered by the user and dividing that by 2 so that the end result is 2 footing lines offset from the middle of 2 picked lines. I have to divide the user entered size by 2 and use that as the offset distance. I think you understand that part. But, when I use the offset value to show the user what the current "Footing Size" is, it is using the "offsetdist" variable, which is only half the footing size. I tried to add something to double the offset size for displaying to the user, but with varied results. Please note that this lisp routine is a compilation of code I mostly received from here. I am trying my best. Check out the code and see if you can make heads or tails of it.

    Thanks. My apologies for pasting this massive code in here. I can't seem to attatch lsp files.

    "Catch" Ya Later,
    AKDRAFTER

    ;;;
    ;;; Footing Creation Routine
    ;;;
    ;;; Timothy J. Jaronik Sr.
    ;;; February, 2004
    ;;;
    ;;; Credit goes to the following people
    ;;; from the Auotdesk Discussion Groups(ADG)
    ;;; for their help with this routine:
    ;;;
    ;;; Joe Burke
    ;;; Bob Shaw
    ;;; TCEBob
    ;;
    ;;;;;;;;;;;;;;;BEGIN ERROR HANDLING FUNCTION;;;;;;;;;;;;;;;
    ;;
    (defun ERRTRAP (msg)
    (princ "\n Error: ")
    (if msg (princ msg))
    (setvar "CLAYER" CLA)
    (setvar "CMDECHO" CME)
    (setvar "OSMODE" OSM)
    (setvar "ORTHOMODE" OTHM)
    (setvar "SNAPMODE" SNM)
    (setq *ERROR* OLDERR)
    (prompt "\n Resetting System Variables... ")
    (princ)
    )
    ;;
    ;;;;;;;;;;;;;;;END ERROR HANDLING FUNCTION;;;;;;;;;;;;;;;
    ;;
    (defun c:FOOTING (/ OLDERR *ERROR* CLA CME OSM OTHM SNM)
    (setq OLDERR *ERROR*)
    (setq *ERROR* ERRTRAP)
    (setq CLA(getvar "CLAYER"))
    (setq CME(getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq OSM(getvar "OSMODE"))
    (setvar "OSMODE" 0)
    (setq OTHM(getvar "ORTHOMODE"))
    (setvar "ORTHOMODE" 0)
    (setq SNM(getvar "SNAPMODE"))
    (setvar "SNAPMODE" 0)
    (setq CURROFF(rtos(getvar "OFFSETDIST")4))
    (setq FOOTSIZ(getdist (strcat "\n Enter Footing Size (Inches)<" CURROFF ">): ")))
    (command "-layer" "thaw" "S-FOOTING" "on" "S-FOOTING" "make" "S-FOOTING" "color" "3" "S-FOOTING" "lt" "hidden" "S-FOOTING" "")
    (setq EN1 (entsel "\n Select The First Line: "))
    (while
    (= EN1 nil)
    (progn
    (prompt "\n Nothing Selected...Select Again: ")
    (setq EN1 (entsel "\n Select The First Line: "))
    )
    )
    (setq EN2 (car EN1))
    (setq EN3 (entget EN2))
    (setq EN4 (cdr (assoc 0 EN3)))
    (while
    (/= "LINE" EN4)
    (progn
    (prompt "\n Not A Line...Select Again: ")
    (setq EN1 nil)
    (setq EN1 (entsel "\n Select The First Line: "))
    (setq EN2 (car EN1))
    (setq EN3 (entget EN2))
    (setq EN4 (cdr (assoc 0 EN3)))
    )
    )
    (setq VAL1 (cdr (assoc 10 EN3)))
    (setq VAL2 (cdr (assoc 11 EN3)))
    (setq DIS1 (distance VAL1 VAL2))

    (setq EN5 (entsel "\n Select The Second Line: "))
    (while
    (= EN5 nil)
    (progn
    (prompt "\n Nothing Selected...Select Again: ")
    (setq EN5 (entsel "\n Select The Second Line: "))
    )
    )
    (setq EN6 (car EN5))
    (setq EN7 (entget EN6))
    (setq EN8 (cdr (assoc 0 EN7)))
    (while
    (/= "LINE" EN8)
    (progn
    (prompt "\n Not A Line...Select Again: ")
    (setq EN5 nil)
    (setq EN5 (entsel "\n Select The Second Line: "))
    (setq EN6 (car EN5))
    (setq EN7 (entget EN6))
    (setq EN8 (cdr (assoc 0 EN7)))
    )
    )
    (setq VAL3 (cdr (assoc 10 EN7)))
    (setq VAL4 (cdr (assoc 11 EN7)))
    (setq VAL5 (cdr (assoc 10 EN7)))
    (setq DIS2 (distance VAL3 VAL4))

    (CHKDIS)
    (CHKCOORD)

    (if (> DIS3 DIS4)
    (progn
    (setq VAL3 VAL5)
    (setq VAL3 VAL4)
    (setq VAL4 VAL5)
    (CHKCOORD)
    )
    )
    (DRWLIN)
    (setq *ERROR* OLDERR)
    (setvar "CLAYER" CLA)
    (setvar "CMDECHO" CME)
    (setvar "OSMODE" OSM)
    (setvar "ORTHOMODE" OTHM)
    (setvar "SNAPMODE" SNM)
    (princ)
    )
    ;;
    (defun RAD2DEG (RD)
    (/ (* RD 180.0) pi)
    )
    ;;
    (defun DEG2RAD (DG)
    (/ (* DG pi) 180)
    )
    ;;
    (defun CHKDIS (/)
    (if (>= DIS1 DIS2)
    (setq DIS3 DIS2)
    (setq DIS3 DIS1)
    )
    (princ)
    )
    ;;
    (defun CHKCOORD (/)
    (setq DIST1 (distance VAL1 VAL3))
    (setq ANG1 (angle VAL1 VAL3))
    (setq DIST2 (distance VAL2 VAL4))
    (setq ANG2 (angle VAL2 VAL4))
    (setq DIST3 (/ DIST1 2))
    (setq DIST4 (/ DIST2 2))
    (setq COORD5 (polar VAL1 ANG1 DIST3))
    (setq COORD6 (polar VAL2 ANG2 DIST4))
    (setq DIS4 (distance COORD5 COORD6))
    (princ)
    )
    ;;
    (defun DRWLIN (/)
    (setq SIDE1(getpoint "\n Pick A Side: "))
    (setq SIDE2(getpoint "\n Pick The Opposite Side: "))
    (command "._line" COORD5 COORD6 "")
    (setq CTRL(entlast))
    (setq COORD7 (polar COORD5
    (angle COORD5 COORD6)
    (/ (distance COORD5 COORD6) 2)
    )
    )
    (command "._change" CTRL "" "p" "layer" "S-FOOTING" "color" "bylayer" "lt" "bylayer" "")
    (command "._offset" (/ FOOTSIZ 2) CTRL SIDE1 CTRL SIDE2 "")
    (command "erase" "p" "")
    (princ)
    )
    ;;
    (prompt "\n Type FOOTING To Run The Footing Creation Routine")
     
    akdrafter, Feb 18, 2004
    #5
  6. akdrafter

    CAB2k Guest

    Try this as an alternative method to drawing your footers.
    You can draw the entire house or just parts.
    Needs more error checking and layer management.

    ;; FooterOffset.lsp
    ;; Created by C. Alan Butler 2004
    ;;
    ;;; Draw a poly line and then offset it & erase the original
    ;;;
    ;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
    ;;; WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
    ;;; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
    ;;;
    ;;;
    ;;
    ;;
    ;; error function & Routine Exit
    (defun *error* (msg)
    (if (not (member msg
    '("console break" "Function cancelled" "quit / exit abort")
    )
    )
    (princ (strcat "\nError: " msg))
    ) ; if
    (princ)
    ) ;
    ;end error function
    ;; pre set global variable, it remember your entry

    ;======================
    ; Start of Routine
    ;======================
    (defun C:FtrOffset (/ pt1 pt2 usercmd str en1 en2)
    ;;; ------- Some Housekeeping ------------------
    (setq usercmd (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setvar "PLINEWID" 0)
    (setq useros (getvar "osmode")
    str "")
    (setvar "osmode" 175)
    (if (null FtrWidth)
    (setq FtrWidth 24); Global variable, do not declare
    )
    (if (null WallWidth)
    (setq WallWidth 12); Global variable, do not declare
    )
    ;;=======================================
    (setq tmp (getreal (strcat "Enter the Footer width : <" (rtos FtrWidth 2 2)">")))
    (if (> tmp 1);could use some error checking
    (setq FtrWidth tmp)
    )
    (setq tmp (getreal (strcat "Enter the Foundation Wall width : <" (rtos WallWidth 2 2)">")))
    (if (> tmp 1);could use some error checking
    (setq WallWidth tmp)
    )

    (setq ShortOfs (/ (- FtrWidth WallWidth) 2.0))
    (setq LongOfs (+ ShortOfs WallWidth))
    (command "undo" "begin")
    (prompt "/nPick points along wall, Enter when done.")
    ;;; Draw the pline
    (setq pt1 (getpoint))
    (command "PLINE" pt1 (Setq pt2 (getpoint pt1))) ;_ COMMAND
    (while (setq pt2 (getpoint pt2 "\nNext point: "))(command pt2)) ;_ WHILE
    (command "")
    (princ)
    (setq en1 (entlast))
    (setvar "osmode" 0)
    (initget 1)
    (setq pto (getpoint "\nPick Side closest to footer edge:"))
    (command "_.offset" ShortOfs en1 pto "")
    (setq pto (getpoint "\nPick Opposite Side footer:"))
    (command "_.offset" LongOfs en1 pto "")
    (entdel en1) ; remove the user drawn line
    (command "undo" "end")


    ;;;========== Exit Sequence ============
    (setvar "osmode" useros)
    (setvar "CMDECHO" usercmd)

    (princ); Exit quietly

    ) ;_end of defun

    ;;; Notify user program ready to use
    (prompt "\n Footer Offsest Loaded: Type 'FtrOffset' to run it.")
    (princ)
     
    CAB2k, Feb 18, 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.