Author Topic: polyline w/ multiplied factor  (Read 4090 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
polyline w/ multiplied factor
« on: November 19, 2004, 07:36:36 PM »
I'm looking for a polyline routine that when asked for a point (x,y), and (x)is inputted, it will multiply (x) by a given number to get (y). Basically something like this
Code: [Select]
Command: pl PLINE
Specify start point: (user to pick point)
Current line-width is 0'-0"
Specify x length: (x= user input or pick from point to point)
("x" multiplied by "s" (s=a given factor)=y)
next point = x,y
repeat
Specify x length: (x= user input or pick from point to point)
("x" multiplied by "s" (s=a given factor)=y)
next point = x,y
repeat


I searched this site to find a similar routine to get me started, but.....maybe someone can point me in the right direction.
Thanx..

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
polyline w/ multiplied factor
« Reply #1 on: November 19, 2004, 11:26:50 PM »
Is the real question "Can one write graphing functions in LISP that will calculate Y as a function of X, using polylines to display the result"?

I would hazard a guess of "Yes".

Of course, my post was a guess in of itself.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
polyline w/ multiplied factor
« Reply #2 on: November 20, 2004, 09:11:47 AM »
danny,
I assume it's the syntax you don't understand. Lisp takes some getting
use to and a lot of practice. You can do almost anything with it, usually
limited by your experience and imagination. I'm sure if you have been reading
the posts here that you know Michael has lots of both.
I will get you started with the basics. If your formula gets complicated
we will defiantly need Michaels help.
Micheal, did I miss anything?

Code: [Select]
;;  start a function & declair local variables after /
(defun c:pl-cal (/ p1 x y)
  (setvar "plinewid" 0) ; set pline width
  (setq p1 (getpoint "\nPick starting point of Line."))
  (command "._pline" p1) ; start the pline
  ;;  loop until user presses Enter
  ;; if the user presses ESCAPE the pline command will not be completed
  ;; you will have to complete it by pressing enter, an *ERROR* handler
  ;; would be needed to catch this condition.
  (while ; loop until the next argument is false (nil)
    ;;  the distance function will allow picked or real number entry
    (setq x (getdist p1 "\nEnter next 'X' value.")) ;p1 gives a starting point
    (setq y (* x 1.5)) ; calc new y value
    (setq p1 (list x y)) ; make a point list, no z, reusing variable p1
    (command p1) ; send the point to the command line
  ) ; end while
  (command "") ; complete the pline by sending ENTER to the command line
  (princ) ; clear the command line & exit
) ; end of defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

danny

  • Guest
polyline w/ multiplied factor
« Reply #3 on: November 22, 2004, 01:09:16 PM »
thanks CAB,
the comments in your lisp help me out in understanding what the function is doing.  If I may, can I ask how to get 'x' & 'y' to be the dist from the last point created.  As of now, 'x' & 'y' will always be the dist from 0,0.
I appreciate the help,

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
polyline w/ multiplied factor
« Reply #4 on: November 22, 2004, 01:17:24 PM »
Quote
To enter an absolute X,Y coordinate, specify a point by entering its X and Y values in the format X,Y. Use absolute X,Y coordinates when you know the precise X and Y values of the location of the point.
For example, to draw a line beginning at an X value of –2 and a Y value of 1, make the following entries on the command line:

Command:  line
From point:  –2,1

To point:  3,4

AutoCAD locates the line as follows:

Use relative X,Y coordinates when you know the position of a point in relation to the previous point. For example, to locate a point relative to –2,1, precede the next coordinate with the @ symbol:

Command:  line
From point:  –2,1

To point:  @5,3

This is the equivalent of entering the absolute coordinate 3,4.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Anonymous

  • Guest
polyline w/ multiplied factor
« Reply #5 on: November 22, 2004, 01:36:28 PM »
entering @ before the x value doesn't work when prompted
Code: [Select]
Enter next 'X' value
so would I put the symbol here?
Code: [Select]
(command @p1)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
polyline w/ multiplied factor
« Reply #6 on: November 22, 2004, 01:57:20 PM »
Try this:
Code: [Select]
;;  start a function & declair local variables after /
(defun c:pl-cal (/ p1 x y)
  (setvar "plinewid" 0) ; set pline width
  (setq p1 (getpoint "\nPick starting point of Line."))
  (command "._pline" p1) ; start the pline
  ;;  loop until user presses Enter
  ;; if the user presses ESCAPE the pline command will not be completed
  ;; you will have to complete it by pressing enter, an *ERROR* handler
  ;; would be needed to catch this condition.
  (while ; loop until the next argument is false (nil)
    ;;  the distance function will allow picked or real number entry
    (setq x (getdist p1 "\nEnter next 'X' value.")) ;p1 gives a starting point
    (setq y (* x 1.5)) ; calc new y value
    ;; make a point string, no z
    (setq p$ (strcat "@" (rtos x 2) "," (rtos y 2)))
    (command p$) ; send the point to the command line
    (setq p1 (getvar "lastpoint")) ; reset p1
  ) ; end while
  (command "") ; complete the pline by sending ENTER to the command line
  (princ) ; clear the command line & exit
) ; end of defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

danny

  • Guest
polyline w/ multiplied factor
« Reply #7 on: November 22, 2004, 02:25:47 PM »
aagh..strcat..works great
Mahalo,

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
polyline w/ multiplied factor
« Reply #8 on: November 22, 2004, 07:24:08 PM »
Sorry CAB / Danny, didn't see the resulting conversation here. Looks like Charles did good by you. The only thing I'd do is keep things very modular; dividing the app into constituent parts, but that's just my habitual divide and conquer approach.

Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst