Help req. making lsp change ltscale of specific linetype after creation

Discussion in 'AutoCAD' started by Friptzap, Apr 7, 2004.

  1. Friptzap

    Friptzap Guest

    I have a routine I created that will draw flex duct. I work as such: Ltscale set to what my intended plot value IE:48 for 1/4"=1'-0" And Psltscale set to 0. The routine sees the ltscale and creates a line that if the input size upon creation was 6" is divides 6 by 48 thus that line will hold an ltscale of .125 if I create another duct that is 8" it does the same thing 8/48 which makes that lines ltscale .666666 the problem is when I may need to change the drawing from 1/4"=1'-0" to 1/8"=1'-0" no matter what the ltscale is new creation works great. A 6" duct will always measure 6" but after the fact the new ltscale effects all currently drawn lines. (psltscale will not help in this matter in no way as I have tested it thoroughly)

    So what this leaves me with is a need for a lisp routine that will allow me to scan the whole drawing for this flex linetype and either :
    1. Input the old ltscale then have it change all these linetype based on what they are currently set at to a new value based on the new ltscale. (6", 8", 10", 12" 14", 16" would all have to be handled separately but they are all the same "flex" linetype.

    2. or just change linetypes based on a "known" value of the existing ltscale of the lines ie:.125 is 6" flex at 1/4"=1'-0" then take this value and input the new ltscale and have it change the value based on this new ltscale. (this would probably be more complicated.)

    I am just not sure where to start with this. I wish I knew some way to make a line know it is supposed to be 6"flex or 8"flex without some complicated associated entity like some 3rd party apps use. Then I could maybe make it look for that entity and change the lines with the 6" value to a new ltscale based on the current ltscale.

    There are many ways this could be done I am sure but I just don't know where to begin. My original post on this was to look for a way for the lines to ignore global AND psltscale vales and not be changed by them automatically. If the line is 6"ltscale and the ignore is set it will be like any 6" object such as a circle and no matter what you plot it at it will always scale 6" wide.

    Any help would be appreciated :)
     
    Friptzap, Apr 7, 2004
    #1
  2. Friptzap

    Friptzap Guest

    anyone able to give me a clue on how to do this?
     
    Friptzap, Apr 8, 2004
    #2
  3. Friptzap

    Jamie Duncan Guest

    (setq ss1 (ssget "X" '(( - the layers or whatever distinguishes these lines
    from the rest))
    then step through and entmod the lines
    ie
    (setq ctr 0 ltsfactor (getreal "\nInput Scale Change"))
    (repeat (sslength ss1)
    (setq end1 (entget (ssname ss1 ctr)) ctr (+ ctr 1))
    (if (setq lts_val (assoc 48 end1)) ;;;ie check the dxf 48 code
    (progn
    (setq end1 (subst (cons 48 (* lts_val ltsfactor))(assoc 48
    end1) end1))
    (entmod end1)(entupd end1)
    )
    )
    )


    or something along these lines.


    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)
     
    Jamie Duncan, Apr 8, 2004
    #3
  4. Friptzap

    Friptzap Guest

    I am such a lisp hack lol (and I don't mean the good kind I just suck lol - I do some decent things as long as I don't get too deep in code).

    The first line should be getting all lines with the linetype named flex.

    These lines will have a value set (they will be different depending on them being 6",8",10",12",14",16" ducts - generated from a lisp that gave them an ltscale that divided the size by the current global ltscale. IE global is 48 so a 6" duct would be 6/48 = the ltscale for a specific 6" duct line)

    Now to change the lines it would have to do all of them at the same time IE:

    3 lines 1=ltscale .125 1=ltscale .166666 1=.208333 representing 6"duct 8"duct 10"duct
    (but these values should not be set in the code because they would be different had the drawing been drawn at 1/8=1'-0" that way no matter what the original drawn by scale the lines could be changed.)

    So it would read all the lines with the linetype called flex then request the original "global" value used to draw them then request the new "global" value they are changing to and then calculate and change the linetype. Mathematically something like this:

    for all current flex linetype values = x
    original global = y
    new global = p
    new linetype values=s

    so for each linetype:
    (x*y)/p=s

    problem is rounding off
    6/48=.125 good here
    8/48-.16666 Infiniti. may cause issues on reverse calcs
    10/48=.208333 same as 8"
    and so on but the round off should be miniscule and not hurt too much.

    This edit command should not rely on global's at this point it should only be used if someone decides the plot scale of the drawings must be changed. I would also like it to have the option to "globally change them all or individually change them incase 10 lines were drawn using the wrong global ltscale and you need to correct them without redrawing them.

    Once drawn the first time the lines will not know what they are specifically IE: a 6"duct drawn at 1/4"=1'-0" will read .125
    while at the same time a 12"duct drawn at 1/8"=1'-0" would read exactly the same. Sorry if this sounds jumbled but this is kinda tricky to explain via web posts :) I hope I sound clear enough :)
     
    Friptzap, Apr 8, 2004
    #4
  5. (setq ss1 (ssget "X" '((6 . "FLEX"))))
    (initget 7) ;;; no 0 or negative or nul real value for ltsfactor
    (setq ctr 0 ltsfactor (getreal "\nInput Scale Change"))
    (repeat (sslength ss1)
    (setq end1 (entget (ssname ss1 ctr)) ctr (+ ctr 1))
    (if (setq lts_val (assoc 48 end1)) ;;;ie check the dxf 48 code
    (progn
    (setq end1 (subst (cons 48 (* lts_val ltsfactor))(assoc 48
    end1) end1))
    (entmod end1)(entupd end1)
    )
    )
    )
    this will do the global scale change thing


    if you want to set a bunch of lines of linetype flex to a given value then
    this is what you want:
    (setq dwgscal nil looper T)
    (while (not (member (setq dwgscal (getint "\nInput Drawing Scale:| ")) (list
    12 24 48 96 192 50 100 200))));;; add or delete scale you use
    (while looper
    (setq ss1 nil)
    (princ "\nSelect Flex Lines to Adjust <Exit>: "
    (setq ss1 (ssget '((6 . "FLEX"))))
    (if (= ss1 nil)
    (setq looper nil)
    (progn
    (setq ctr 0)
    (initget 7)
    (setq duct_size (getdist "\nInput New Duct Size: "))
    (repeat (sslength ss1)
    (setq end1 (entget (ssname ss1 ctr)) ctr (+ ctr 1))
    (if (setq lts_val (assoc 48 end1)) ;;;ie check the dxf 48 code
    (progn
    (setq end1 (subst (cons 48 (/ duct_size dwgscal))(assoc 48
    end1) end1))
    (entmod end1)(entupd end1)
    )
    )
    )
    ))





    The above will do what you want - user needs to put in lts factor ie if
    going from 1:48 to 1:96, ltsfactor is 0.5.
    the other way it would be 2 - thus user controls lts change for the lines of
    linetype flex that had their ltscale set to a value
    --


    Jamie Duncan

    Consulting - If you're not part of the solution, there's good money in
    prolonging the problem.
    lol - I do some decent things as long as I don't get too deep in code).
    them being 6",8",10",12",14",16" ducts - generated from a lisp that gave
    them an ltscale that divided the size by the current global ltscale. IE
    global is 48 so a 6" duct would be 6/48 = the ltscale for a specific 6" duct
    line)
    different had the drawing been drawn at 1/8=1'-0" that way no matter what
    the original drawn by scale the lines could be changed.)
    the original "global" value used to draw them then request the new "global"
    value they are changing to and then calculate and change the linetype.
    Mathematically something like this:
    be used if someone decides the plot scale of the drawings must be changed. I
    would also like it to have the option to "globally change them all or
    individually change them incase 10 lines were drawn using the wrong global
    ltscale and you need to correct them without redrawing them.
    specifically IE: a 6"duct drawn at 1/4"=1'-0" will read .125
    the same. Sorry if this sounds jumbled but this is kinda tricky to explain
    via web posts :) I hope I sound clear enough :)
     
    Jamie Duncan \(remove lock to reply\), Apr 8, 2004
    #5
  6. --


    Jamie Duncan

    Consulting - If you're not part of the solution, there's good money in
    prolonging the problem.
    lol - I do some decent things as long as I don't get too deep in code).
    them being 6",8",10",12",14",16" ducts - generated from a lisp that gave
    them an ltscale that divided the size by the current global ltscale. IE
    global is 48 so a 6" duct would be 6/48 = the ltscale for a specific 6" duct
    line)
    different had the drawing been drawn at 1/8=1'-0" that way no matter what
    the original drawn by scale the lines could be changed.)
    the original "global" value used to draw them then request the new "global"
    value they are changing to and then calculate and change the linetype.
    Mathematically something like this:
    be used if someone decides the plot scale of the drawings must be changed. I
    would also like it to have the option to "globally change them all or
    individually change them incase 10 lines were drawn using the wrong global
    ltscale and you need to correct them without redrawing them.
    specifically IE: a 6"duct drawn at 1/4"=1'-0" will read .125
    the same. Sorry if this sounds jumbled but this is kinda tricky to explain
    via web posts :) I hope I sound clear enough :)
     
    Jamie Duncan \(remove lock to reply\), Apr 8, 2004
    #6
  7. Friptzap

    Friptzap Guest

    oh great I will try that early next week if I can't get to it sooner. I will let you know how it turns out. Thanks a bunch :)
    I have a bit of a project to finish so I cannot get back to this till monday (I hope sooner while it is all fresh in my head)
     
    Friptzap, Apr 8, 2004
    #7
  8. Friptzap

    Friptzap Guest

    rats.... I keep getting this on appload:

    Command: appload
    FLEXfix1.LSP successfully loaded.
    Command:
    Input Scale Change2
    ; error: bad argument type: numberp: (48 . 0.25)

    and a similar problem on the second one:
    Command:
    APPLOAD FLEXfix2.LSP successfully loaded.
    Command:
    Input Drawing Scale:| 96
    ; error: malformed list on input
     
    Friptzap, Apr 8, 2004
    #8
  9. My bad - forgot to add a cdr, and parentheses stuff - try these

    (setq ss1 (ssget "X" '((6 . "FLEX"))))
    (initget 7) ;;; no 0 or negative or nul real value for ltsfactor
    (setq ctr 0 ltsfactor (getreal "\nInput Scale Change"))
    (repeat (sslength ss1)
    (setq end1 (entget (ssname ss1 ctr)) ctr (+ ctr 1))
    (if (setq lts_val (cdr (assoc 48 end1))) ;;;ie check the dxf 48
    code
    (progn
    (setq end1 (subst (cons 48 (* lts_val ltsfactor))(assoc 48
    end1) end1))
    (entmod end1)(entupd end1)
    )
    )
    )

    (defun c:setflexsize (/ ss1 looper ctr duct_size dwg_scal)
    (setq dwg_scal nil looper T)
    (while (not (member (setq dwg_scal (getint "\nInput Drawing Scale: "))
    (list 12 24 48 96 192 50 100 200))));;; add or delete scale you use
    (while looper
    (setq ss1 nil)
    (princ "\nSelect Flex Lines to Adjust <Exit>: ")
    (setq ss1 (ssget '((6 . "FLEX"))))
    (if (= ss1 nil)
    (setq looper nil)
    (progn
    (setq ctr 0)
    (initget 7)
    (setq duct_size (getdist "\nInput New Duct Size: "))
    (repeat (sslength ss1)
    (setq end1 (entget (ssname ss1 ctr)) ctr (+ ctr 1))
    (if (assoc 48 end1);;;ie check the dxf 48 code
    (setq end1 (subst (cons 48 (/ duct_size
    dwg_scal))(assoc 48 end1) end1))
    (setq end1 (append (list (cons 48 (/ duct_size
    dwg_scal))) end1))
    );;; end if
    (entmod end1)(entupd end1)
    );;; end repeat
    );;; end progn
    );;;endif
    );;; looper while
    )


    There, that should do it! (rubbinghandstogetherwithglee.wav)



    --
    Jamie Duncan

    "Maybe the Hokey Pokey is REALLY what's it all about"



    --


    Jamie Duncan

    Consulting - If you're not part of the solution, there's good money in
    prolonging the problem.
     
    Jamie Duncan \(remove lock to reply\), Apr 8, 2004
    #9
  10. Friptzap

    Friptzap Guest

    WOW amazing these work great :) They function just like I want. Only a couple minor flaws.

    The first routine does not like when I add a defun to it and it seems to only work on the last entity of that linetype drawn. It will not change all of the lines of that linetype only the last one drawn.

    The second routine works great also but if I select multiple ducts at one time that need to change it will only change 1 of them. The nice thing about it also is I can change for a different scale factor and size at the same time. You have it change the lines based solely on the new input rather than calculating from its current status. Which gets rid of the problem of tolerance.

    With those changes I would be tickled pink :) Then later maybe I can figure it out. Just cracked open my old lisp book after 5 years last night but this is a little deeper than my current ability.

    I hope you can still help me with it :)
    Thanks again. - this really makes my day I really hated block insertions. I just wonder which is better for file size custom linetype using a font like this or a line with a block insertion along its path :)
     
    Friptzap, Apr 9, 2004
    #10
  11. Friptzap

    Jamie Duncan Guest

    Hey Frip,

    would you send me that drawing file in r200? then I can test them here,
    okay?

    Thanks.


    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)

    only work on the last entity of that linetype drawn. It will not change all
    of the lines of that linetype only the last one drawn.
    time that need to change it will only change 1 of them. The nice thing about
    it also is I can change for a different scale factor and size at the same
    time. You have it change the lines based solely on the new input rather than
    calculating from its current status. Which gets rid of the problem of
    tolerance.
    figure it out. Just cracked open my old lisp book after 5 years last night
    but this is a little deeper than my current ability.
    I just wonder which is better for file size custom linetype using a font
    like this or a line with a block insertion along its path :)
     
    Jamie Duncan, Apr 9, 2004
    #11
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.