Lisp routine help

Discussion in 'AutoCAD' started by David, Jun 8, 2004.

  1. David

    David Guest

    I'm making the move from R14 to 2005 and this is pretty much my last
    unresolved problem.

    this lisp routine draws a squiggly poly line.

    The routine itself works fine and seems to display properly on the screen
    but when its plotted out in 2005 the line is extremely fine like its
    ignoring the line weight I assigned to the color. In r14 it plots out as a
    nice thick bold line. Anyway I can fix the problem with the squiggly poly
    line manually by exploding it or using pedit and changing the width but I
    use this a lot and that will become very cumbersome and time consuming.

    Is there any way that the width of the pline used in this lisp can be
    increased? Here is a cut and paste of the routine. TIA

    ;This Command Draws squiggly polylines.
    ;
    (defun c:sq (/ pl p1 p3 dst an ll dsc cd nc p2 np w np pl up)
    (setq cce (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq p1 (getpoint "\nChoose Start Point: ")
    p3 (getpoint p1 "\nChoose End Point: ")
    dst (distance p1 p3)
    an (angle p1 p3)
    ll (/ (getvar "ltscale") 25.0)
    dsc (- dst (* 3.0 ll))
    nc (fix (/ dsc (* 7 ll)))
    nc (if (zerop nc) 1 nc)
    cd (/ dsc nc)
    p2 (polar p1 an ll)
    np p2
    pl (list np)
    w (/ ll 7))
    (repeat nc
    (setq np (polar np an cd)
    pl (append pl (list np)))
    )
    (command "pline" p1 "w" w w p2 "a")
    (foreach p (cdr pl)
    (command "d")
    (if up
    (progn
    (setq up nil)
    (command (angtos (+ an 250) 0 0))
    )
    (progn
    (setq up T)
    (command (angtos (- an 250) 0 0))
    )
    ) ;ends if
    (command p)
    ) ;ends foreach
    (command "l" p3 "") ;ends command
    (setvar "CMDECHO" cce)
    ) ;ends
    
     
    David, Jun 8, 2004
    #1
  2. David

    T.Willey Guest

    I don't have 2005, but you are setting the width of the polyline in your lisp. That is why it won't print out think. You are dividing your ltscale by 25 then you divide that number by 7 to get the thickness of your polyline. If a polyline has a thickness assigned to it, then when plotted it goes by that number instead of the pen thickness.

    I would just get a new thickness that you like and use that, or find a new equation that works for you and prints the way you want it to.

    Tim
     
    T.Willey, Jun 8, 2004
    #2
  3. David

    David Guest

    Thanks for the quick reply. the layer is labeled default for line weight so
    that should be alright and the color is bylayer so it should plot out to the
    line width i have specified in the ctb for that color but it wont.
     
    David, Jun 8, 2004
    #3
  4. David

    David Guest

    Thanks for the quick reply.
    Do you think by taking out the lines dealing with the pline width in the
    routine that it would cause it to print out using the line weight I have
    specified for that specific color?
    lisp. That is why it won't print out think. You are dividing your ltscale
    by 25 then you divide that number by 7 to get the thickness of your
    polyline. If a polyline has a thickness assigned to it, then when plotted
    it goes by that number instead of the pen thickness.
    equation that works for you and prints the way you want it to.
     
    David, Jun 8, 2004
    #4
  5. David

    David Guest

    Well I did what I asked in my previous question about deleting the lines
    that delt with the pline width and it worked perfectly.. thanks alot for
    your help you da man.
     
    David, Jun 8, 2004
    #5
  6. David

    CAB2k Guest

    David,
    Here is one I wrote a few days ago, doesn't have the straight line
    segment on each end though.

    Code:
    ;;;  wave.lsp by Charles Alan Butler
    ;;;         Copyright 2004
    ;;;  by Precision Drafting & Design All Rights Reserved.
    ;;;  Contact at 
    ;;;
    ;;;   Version 1.0 Beta  June6, 2004
    ;;;
    ;;; DESCRIPTION
    ;;; Creates wavy line on current layer
    ;;;
    ;;;  Limitations : Unknown at this time
    ;;;
    ;;; Command Line Usage
    ;;; Command: wave
    ;;;
    ;;;   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.
    ;;;                                                                    ;
    ;;;  You are hereby granted permission to use, copy and modify this    ;
    ;;;  software without charge, provided you do so exclusively for       ;
    ;;;  your own use or for use by others in your organization in the     ;
    ;;;  performance of their normal duties, and provided further that     ;
    ;;;  the above copyright notice appears in all copies and both that    ;
    ;;;  copyright notice and the limited warranty and restricted rights   ;
    ;;;  notice below appear in all supporting documentation.              ;
    
    (defun c:wave (/ sp ep ang wl dist a90 a270 step arcdia)
    (defun *error* (msg)
    (if
    (not
    (member
    msg
    '("console break" "Function cancelled" "quit / exit abort" "")
    )
    )
    (princ (strcat "\nError: " msg))
    ) ; if
    (setvar "cmdecho" usercmd) ;cab
    (setvar "osmode" useros) ;cab
    (setvar "plinewid" userplw) ;cab
    (princ)
    ) ; defun
    ;end error function
    
    ;;;================================================================
    ;;;                    Start of Routine
    ;;;================================================================
    
    (setq usercmd (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq useros (getvar "osmode"))
    (setq userplw (getvar "plinewid"))
    (setvar "osmode" 0)
    (setvar "plinewid" 0) ; set polyline width here
    (prompt (strcat "\nWave length is aproximate total of two arcs."
    "\nActual arc length is adjusted to fit between end points."))
    (if (and
    (setq wl (getdist "\nWave Length: "))
    (setq sp (getpoint "\nPick start point: "))
    (setq ep (getpoint sp "\nPick end point: "))
    )
    (progn
    (setq dist   (distance sp ep)
    ANG    (angle sp ep)
    a90    (/ pi 2)
    a270   (* pi 1.5)
    arcdia (/ wl 2.0)
    step   (/ dist (max(fix (+ (/ dist arcdia) 0.5))1))
    )
    ;;  for full arc wave look change 90 to 180
    (command ".pline" sp "a" "a" 90 (setq sp (polar sp ang step)))
    (repeat (1-(fix (/ dist step)))
    (command (setq sp (polar sp ang step)))
    )
    (command "")
    ) ; end progn
    ) ; endif
    (*error* "")
    (princ)
    ) ; end defun
    (prompt "\nWAVE loaded enter wave to run.")
    (princ)
     
    CAB2k, Jun 9, 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.