Center lines for dimension lines.

Discussion in 'AutoCAD' started by T.Willey, Jun 15, 2004.

  1. T.Willey

    T.Willey Guest

    I have this lisp that changes the ltype of dimension lines so that they show up as center (thanks to this group). The problem is when I do anything to them they change back.

    Does anyone know how to make the changes stick? or can anyone tell me the reason behind this.

    Thanks,
    Tim
     
    T.Willey, Jun 15, 2004
    #1
  2. Please post the lisp program, so that we can see what is happening.
     
    Alan Henderson @ A'cad Solutions, Jun 16, 2004
    #2
  3. T.Willey

    T.Willey Guest

    Code:
    (defun c:cl(/ ob1 ob2 ob3 ob4)
    
    (command "undo" "end")
    (command "undo" "group")
    (lt-check)
    (setvar "errno" 0)
    (setq ob1 nil)
    (while (and (/= (getvar "errno") 52) (not ob1))
    (setq ob1 (nentsel "\nSelect dimension line to change to center linetype: "))
    (if (= (vl-list-length ob1) 4)
    (progn
    (setq ob2 (entget (caar (cdddr ob1))))
    (if (= (cdr (assoc 0 ob2)) "DIMENSION")
    (progn
    (setq ob3 (entget (car ob1)))
    (if (assoc 6 ob3)
    (setq ob4 (subst (cons 6 "CENTER2") (assoc 6 ob3) ob3))
    (setq ob4 (append ob3 (list (cons 6 "CENTER2"))))
    ); end if
    (entmod ob4)
    (entupd (cdr (assoc -1 ob2)))
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    (setq ob1 nil)
    ); end while
    
    (command "undo" "end")
    (princ)
    ); end function
    
    
    (defun lt-check(/ tb1 ltlist1)
    (setq tb1 (tblnext "ltype" T))
    (setq ltlist1 (list (cdr (assoc 2 tb1))))
    (while (setq tb1 (tblnext "ltype"))
    (setq ltlist1 (append ltlist1 (list (cdr (assoc 2 tb1)))))
    )
    (if (not (member "CENTER2" ltlist1))
    (command "-linetype" "l" "CENTER2" "ACAD.LIN" "")
    )
    )
    
    Since Luis says that the way I do it, it won't last because I use entmod, is there another way to do it? I guess I could just redraw that entiy and make it have the ltype I want, but I was hoping to have it still be associative.

    Is there any options then to keep it associative and be the ltype I want all the time??

    Thanks,
    Tim
     
    T.Willey, Jun 16, 2004
    #3
  4. If the dimensions are measuring to actual centerlines of something, I'd be
    inclined to draw the centerlines separately from the dimensions, since you
    might want them to appear even with dimensions turned off. Then add the
    dimensions with their extension lines suppressed, so they don't draw through
    the gaps in the centerlines. That's what we do with building column grids.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Jun 16, 2004
    #4
  5. T.Willey

    T.Willey Guest

    The way it's looking that maybe the way it has to be done, but I really hoping that it to be associated with the dimension. If it can't be done than I will have to do it that way.

    Tim
     
    T.Willey, Jun 16, 2004
    #5
  6. If you can stand the thought of the dimension lines being the Center
    linetype, in addition to the extension lines, you could assign that linetype
    to your dimensions layer. Is that too wacky a solution?

    Kent Cooper, AIA


    hoping that it to be associated with the dimension. If it can't be done
    than I will have to do it that way.
     
    Kent Cooper, AIA, Jun 16, 2004
    #6
  7. T.Willey

    T.Willey Guest

    Ya, because then the line that the dimension text sits on is going to be center ltype, and if you dimension from endpoint to center, the endpoint dim line will also be center ltype.

    But at least you are trying to find a solution...=D..Thanks for that.

    Tim
     
    T.Willey, Jun 16, 2004
    #7
  8. T.Willey

    ECCAD Guest

    You might try this one:

    (defun C:CL (/ e)
    (vl-load-com)
    (setq e (entsel))
    (setq obj (vlax-ename->vla-object (car e)))
    (vlax-put-property obj 'linetype "CENTER2")
    (vlax-dump-object obj T)
    (princ)
    ); end function
    (C:CL)

    Bob
     
    ECCAD, Jun 16, 2004
    #8
  9. T.Willey

    T.Willey Guest

    Bob,

    That changed all the lines to center2 ltype. I wanted it to only change the one dim line that I selected to change ltype. If you know of a way to do it, others say it can't be done because the extension lines get redrawn when you stretch or move the dimension.

    Thanks for trying,
    Tim
     
    T.Willey, Jun 16, 2004
    #9
  10. T.Willey

    ECCAD Guest

    Yes, it will change the linetype - of the entire DIMENSION, not just a 'chunk' of it. When you change it, it should stay as CENTER2.

    I don't think you can just change a 'piece' of the definition, because it has only (1) place to store the linetype definition, which is applied to the 'object' as a property...

    Bob
     
    ECCAD, Jun 16, 2004
    #10
  11. T.Willey

    T.Willey Guest

    This idea mabe way out there, but could you
    pick the dim line to change
    draw a line with center2 ltype
    turn off said dim line
    make two reactors to stretch the new line

    Say you stretch the reference point down, then the line would stretch down that lenght. If you stretch the location of the dim text up or down, the new line would stretch just like a real dimension line. Finally if you erase the dimension the line would erase also. I guess you would need three reactors. I don't know anything about reactors, as how to write them, so I would need some help if you think this is a possible solution.

    Tim
     
    T.Willey, Jun 16, 2004
    #11
  12. T.Willey

    ECCAD Guest

    It might be a whole lot simpler, just to draw a 'continuous' line right over the 2nd vector, and leave the Center2 linetype.
    Do a line, pick each 'endpoint' to cover-up the center2 vector ?
    Bob
     
    ECCAD, Jun 16, 2004
    #12
  13. T.Willey

    T.Willey Guest

    I sorry... I don't understand what you mean. Could you please explain more.

    Thanks,
    Tim
     
    T.Willey, Jun 16, 2004
    #13
  14. Try this lisp, or download it for free at www.timesaversforcad.com

    ;=========================================================================

    ; DIMCL.lsp Dimension Centerline (Command function for AutoCAD)
    ; (c) Copyright 2001 TimeSavers for CAD
    ; from: www.timesaversforcad.com
    ;-------------------------------------------------------------------------

    ; Description:
    ;
    ; Changes linetype of an Associative Dimension extension line.
    ; Function actually modifies length of extension line<s> to
    ; shortest length, draws LINE in place of previous extension
    ; line<s> with specified linetype.
    ;
    ; Command options:
    ; "L" to change linetype - sets global DCL_T
    ; "S" to change ltscale - sets global DCLT_S
    ;============================================================================

    (defun c:dimcl (/ *dc:err* c_e o_m g ss ssl ed c1 p0 p10 p13 p14 a# arad
    p1 p2
    fp1 fp2 dst ldst lyr flyr dxo dxe tdd l_t)

    ;-ERROR HANDLING
    (defun *dc:err* (m)
    (or (member m '("Function cancelled" "quit / exit abort" "console
    break"))
    (prompt (strcat "\n< " m " >\n"))
    )
    (setvar "osmode" o_m)(setvar "cmdecho" c_e)
    (setq *error* *e*)(princ)
    )

    ;-GET VALUES
    (setq *e* (cond (*e*)(*error*))
    *error* *dc:err*
    c_e (getvar "cmdecho")
    o_m (getvar "osmode")
    )
    (setvar "cmdecho" 0)
    (or dcl_t (setq dcl_t "center2x"))
    (or (tblsearch "LTYPE" dcl_t)
    (command "linetype" "l" dcl_t "acad.lin" "")
    (tblsearch "LTYPE" dcl_t)
    (prompt (strcat "\nDefault linetype " (strcase dcl_t) " not
    valid."))
    (setq dcl_t nil)
    )
    (or (= (type dclt_s) 'REAL)(setq dclt_s 0.5000))

    ;-MAIN FUNCTION
    (while (and dcl_t dclt_s
    (not (command "undo" "e" "undo" "g"))
    (setvar "osmode" 512)
    (setq ldst 0 ss nil g T)
    (while (and g
    (or (initget "Ltype ltScale ")
    (setq c1 (getpoint (strcat "\nLtype: "
    (strcase dcl_t) " / ltScale: " (rtos dclt_s 2) " /<Pick Extension Line>:
    ")))
    )
    )
    (cond ((= c1 "Ltype")
    (while (and (/= "" (setq l_t (getstring (strcat
    "\nLinetype <" dcl_t ">: "))))
    (not (or (tblsearch "LTYPE" l_t)
    (command "linetype" "L" l_t "acad.lin"
    "")
    (tblsearch "LTYPE" l_t)
    )
    )
    )
    )
    (or (= l_t "")(setq dcl_t l_t))
    )
    ((= c1 "ltScale")
    (if (setq lt_s (getreal (strcat "\nLinetype
    Scale <" (rtos dclt_s 2) ">: ")))
    (setq dclt_s lt_s)
    )
    )
    ((setq ss (ssget "C" c1 c1 '((0 .
    "DIMENSION"))))(setq g nil))
    ((setq ssl (ssget "C" c1 c1 '((0 . "LINE"))))
    (setq ssl (ssname ssl 0) ed (entget ssl) g nil)
    )
    ((princ "0 found."))
    )
    (or ss ssl)
    )
    )
    (setq g 0)
    (setvar "osmode" 0)
    (while (and ss (< g (sslength ss)))
    (setq ed (entget (ssname ss g))
    p10 (cdr (assoc 10 ed))
    p13 (cdr (assoc 13 ed))
    p14 (cdr (assoc 14 ed))
    arad (cdr (assoc 50 ed))
    lyr (cdr (assoc 8 ed))
    p0 (cond ((= arad 0)(cons (car p13)(cdr p10)))
    ((= arad >90)(cons (car p10)(cdr p13)))
    ((inters p10 (polar p10 arad 1.0) p13 (polar p13 (+
    arad (* 0.5 pi)) 1.0) nil))
    )
    tdd (tblsearch "dimstyle" (cdr (assoc 3 ed)))
    dxo (* (cdr (assoc 42 tdd))(getvar "dimscale"))
    dxe (* (cdr (assoc 44 tdd))(getvar "dimscale"))
    )
    (if (cond ((inters c1 c1 p10 p14)(setq p1 p10 p2 p14 a# 14))
    ((inters c1 c1 p0 p13)(setq p1 p0 p2 p13 a# 13))
    )
    (progn
    (entmod (list (assoc -1 ed)(cons a# (if (> dxo dxe)(polar p1
    (angle p1 p2)(- dxo dxe)) p1))))
    (if (> (setq dst (distance p1 p2)) ldst)
    (setq ldst dst fp1 p1 fp2 p2 flyr lyr)
    )
    )
    (prompt "Must be an Extension line.")
    )
    (setq g (1+ g))
    )
    (if ssl
    (progn
    (setq fp1 (cdr (assoc 10 ed))
    fp2 (cdr (assoc 11 ed))
    flyr (cdr (assoc 8 ed))
    )
    (entdel ssl)(setq ssl nil)
    )
    )
    (if fp1 ;found at least 1 assoc. dimension extension line or single
    line
    (entmake (list '(0 . "LINE")
    (cons 8 flyr)
    (cons 6 dcl_t)
    (cons 48 dclt_s)
    (cons 10 (if ss (polar fp1 (angle fp2 fp1) dxe)
    fp1))
    (cons 11 (if ss (polar fp2 (angle fp2 fp1) dxo)
    fp2))
    )
    )
    )
    )

    ;-RETURN VARIABLES
    (setvar "cmdecho" c_e)(setvar "osmode" o_m)
    (setq *error* *e*)
    (princ)
    )
    ;-END FILE
     
    Harold Leveritt, Jun 23, 2004
    #14
  15. Given the description of what this actually does, I'd be wary and test it
    thoroughly. It sounds like you'd lose some aspect of associativity on the
    dimension. If you stretch things including the defpoint(s), is that
    centerline line it draws going to move the way a dimension's extension line
    should, or might one end of it stay where it was?

    Kent Cooper, AIA


    .....
     
    Kent Cooper, AIA, Jun 23, 2004
    #15
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.