Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

feed points from variables.

19 REPLIES 19
Reply
Message 1 of 20
Anonymous
407 Views, 19 Replies

feed points from variables.

Question,

I have the x y and z coordinate as separate variables in a Lisp routine
gathered from line segments, but how do you combine them into one variable
that is understood as a point in space?

Example.
I want a line drawn from the x of line 1
the y of line 2
and the z of line 3
to ect.....

I can get the x y and z from the different line segments, but how do you put
it back together?


Thomas D. Wooton
Southern Systems Inc.
19 REPLIES 19
Message 2 of 20
Anonymous
in reply to: Anonymous

(list x y z)
--
Bobby C. Jones
Dots & Parens living in harmony...
Message 3 of 20
Anonymous
in reply to: Anonymous

I have put the list into the program and it gives me an error (invalid 2d/3d
point). Am I putting it in correctly?

(setq d1 (list x1 y2 z3))

this gived me a list like (4.0 4.0 0) which autocad can't use for input as a
3d point. It is just a text string. How do you get it to accept or create a
variable which is a point in space?



"Bobby Jones" wrote in message
news:f089fc7.0@WebX.maYIadrTaRb...
> (list x y z)
> --
> Bobby C. Jones
> Dots & Parens living in harmony...
>
>
>
Message 4 of 20
Anonymous
in reply to: Anonymous

Thomas, could you post all of the code? Thanks.
--
Bobby C. Jones
Dots & Parens living in harmony...
Message 4 of 20
Anonymous
in reply to: Anonymous

Points need to be reals. i.e. (4.0 4.0 0.0)

-Jason


"Thomas D. Wooton" wrote in message
news:F502D08030F5EAFD08486AD01A1F51E2@in.WebX.maYIadrTaRb...
> I have put the list into the program and it gives me an error (invalid
2d/3d
> point). Am I putting it in correctly?
>
> (setq d1 (list x1 y2 z3))
>
> this gived me a list like (4.0 4.0 0) which autocad can't use for input as
a
> 3d point. It is just a text string. How do you get it to accept or create
a
> variable which is a point in space?
>
>
>
> "Bobby Jones" wrote in message
> news:f089fc7.0@WebX.maYIadrTaRb...
> > (list x y z)
> > --
> > Bobby C. Jones
> > Dots & Parens living in harmony...
> >
> >
> >
>
>
Message 6 of 20
Anonymous
in reply to: Anonymous

"Bobby Jones" wrote in message
news:295F86FC3FD3EC6239B65D06DA42EFB9@in.WebX.maYIadrTaRb...
> Thomas, could you post all of the code? Thanks.
> --
> Bobby C. Jones
> Dots & Parens living in harmony...
>
>
>
Message 7 of 20
Anonymous
in reply to: Anonymous

It appears as though Jason's eye, or is that Jason's mind, is sharper than
mine. Change this line of code:
(setq d1 (list answerx answery 0))

to
(setq d1 (list answerx answery 0.0))

to fix the invalid point problem.
--
Bobby C. Jones
Dots & Parens living in harmony...
Message 8 of 20
Anonymous
in reply to: Anonymous

>It appears as though Jason's eye, or is that Jason's mind, is sharper than
mine.

Nah. I think it is that VBA corruption on your end 🙂

-Jason


"Bobby Jones" wrote in message
news:CE02F0E184013B67B01F5AAAFF0FFD2D@in.WebX.maYIadrTaRb...
> It appears as though Jason's eye, or is that Jason's mind, is sharper than
> mine. Change this line of code:
> (setq d1 (list answerx answery 0))
>
> to
> (setq d1 (list answerx answery 0.0))
>
> to fix the invalid point problem.
> --
> Bobby C. Jones
> Dots & Parens living in harmony...
>
>
>
>
Message 9 of 20
Anonymous
in reply to: Anonymous

> Points need to be reals. i.e. (4.0 4.0 0.0)

I do not think so:

Command: (distance '(4.0 4.0 0.0) '(8 8 0))
5.65685

Command: (distance '(4 4 0) '(8 8 0))
5.65685

Command: (distance '(4.0 4.0 0.0) '(8.0 8.0 0.0))
5.65685


Marco
Message 10 of 20
Anonymous
in reply to: Anonymous

(princ "\n*a answerx: ")(prin1 (setq a answerx))(princ "\n");èèèè
(princ "\n*b answery: ")(prin1 (setq b answery))(princ "\n");èèèè
(princ "\n*c d1 : ")(prin1 (setq c d1 ))(princ "\n");èèèè
(princ "\n*d dis1 : ")(prin1 (setq d dis1 ))(princ "\n");èèèè

*a answerx: -115.263

*b answery: 256.27

*c d1 : (-115.263 256.27 0)

*d dis1 : 227.996 <<<<<<<<<<<<<<<<<<< need a point list

error: bad argument type
(DISTANCE DIS1 D1)

*********************************************************
distance:
Returns the 3D distance between two points

(distance pt1 pt2)

(distance '(1.0 2.5 3.0) '(7.7 2.5 3.0)) returns 6.7

(distance '(1.0 2.0 0.5) '(3.0 4.0 0.5)) returns 2.82843

If one or both of the supplied points is a 2D point,
then distance ignores the Z coordinates of any 3D points
supplied and returns the 2D distance between the points
as projected into the current construction plane.

Marco
Message 11 of 20
Anonymous
in reply to: Anonymous

Uh, I think integers will do fine as well.

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"Jason Piercey" wrote in message
news:D167847E4910EC10FCB39695F1493431@in.WebX.maYIadrTaRb...
> Points need to be reals. i.e. (4.0 4.0 0.0)
>
> -Jason
Message 12 of 20
Anonymous
in reply to: Anonymous

Just for your info, since it seems that you're not interested in any Z
values, you could skip the Z component altogether, since the (distance)
function will return the 2D distance if given only '(x y).

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"Thomas D. Wooton" wrote in message
news:E6394116B611AAB4159937A563C1FEBD@in.WebX.maYIadrTaRb...
>
> "Bobby Jones" wrote in message
> news:295F86FC3FD3EC6239B65D06DA42EFB9@in.WebX.maYIadrTaRb...
> > Thomas, could you post all of the code? Thanks.
> > --
> > Bobby C. Jones
> > Dots & Parens living in harmony...
> >
> >
> >
>
>


----------------------------------------------------------------------------
----


> ; kip.lsp
> ; BY Thomas D. Wooton 10/07/01
> ;
*************************************************************************
> ; *
*
> ; * Inputs kip loading numbers (Kilo/pounds) of weight distributed
*
> ; * over the specified supports. Start by selecting your conveyor path
*
> ; * (centerline of weight) and then your panel points (support points).
*
> ; * next enter the average weight per foot. The program then generates
*
> ; * your kip loads and inputs them at the panel points.
*
> ; *
*
> ;
*************************************************************************
> ;
> (DEFUN DTR (A)
> (* PI (/ A 180.0))
> )
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; List line
length
> (defun C:LL (/ ENAME SP EP DIS)
> ; screen prompts for info
> (setq ENAME1 (entget (car (entsel "\nSelect Conveyor line: "))))
> (setq ENAME2 (entget (car (entsel "\nSelect Support line: "))))
> (setq lbs (getint "\nAverage Weight Per Foot "))
> ; finding the x,y I need
> (setq ETYPE1 (cdr (assoc 0 ENAME1)))
> (setq SP1 (cdr (assoc 10 ENAME1)))
> (setq EP1 (cdr (assoc 11 ENAME1)))
> (setq x1 (car sp1))
> (setq y1 (cadr sp1))
> (setq x2 (car ep1))
> (setq y2 (cadr ep1))
> (setq ETYPE2 (cdr (assoc 0 ENAME2)))
> (setq SP2 (cdr (assoc 10 ENAME2)))
> (setq EP2 (cdr (assoc 11 ENAME2)))
> (setq x3 (car sp2))
> (setq y3 (cadr sp2))
> (setq x4 (car ep2))
> (setq y4 (cadr ep2))
> (if (= ETYPE1 ETYPE2 "LINE")
> (progn
> ; calculates length of lines
> (setq DIS1 (distance SP1 EP1))
> (setq ANG1 (angle SP1 EP1))
> (setq DIS2 (distance SP2 EP2))
> (setq ANG2 (angle SP2 EP2))
> ; calculates intersection of lines
> ; I did not want to use the inters function because if they don't
intersect I want it to error.
> (setq ua (/ (- (* (- x4 x3) (- y1 y3)) (* (- y4 y3) (- x1 x3)))
(- (* (- y4 y3) (- x2 x1)) (* (- x4 x3) (- y2 y1)))))
> (setq answerx (+ x1 (* ua (- x2 x1))))
> (setq answery (+ y1 (* ua (- y2 y1))))
> ;
> ;
> ; Here is where I am wanting to take the x and y above and make a point so
> ; I can find the distance from this point to the start points and end
points of each line.
> ; If you draw two intersecting lines and run the routine you will get the
info
> ; I have been able to extract and manipulate so far.
> ; The intersection to end distance, divided by the total length, gives me
a percentage of
> ; the total distance. Multiply this by your average weight, to find how
much
> ; weight is on each end of your supports. Ie your moment of inertia
> ;
> (setq d1 (list answerx answery 0))
> ;
> ;
> ;
> ;
> ; calculates weight of each point
> (setq kip1 (* (distance dis1 d1) lbs))
> (setq kip2 (* (distance dis1 d1) lbs))
> (setq kip3 (* (distance dis2 d1) lbs))
> (setq kip4 (* (distance dis2 d1) lbs))
> ; screen prompts
> (prompt "\nDistance = ")(princ dis1)
> (prompt "\nStart Point = ")(princ SP1)
> (prompt "\nEnd Point = ")(princ EP1)
> (prompt (strcat " Angle = " (angtos ANG1 0 4)))
> (prompt (strcat "\nLength = " (rtos DIS1 4 4)))
> (prompt "\nDistance = ")(princ dis2)
> (prompt "\nStart Point = ")(princ SP2)
> (prompt "\nEnd Point = ")(princ EP2)
> (prompt (strcat "\nLength = " (rtos DIS2 4 4)))
> (prompt "\nX1 = ")(princ x1)
> (prompt "\nY1 = ")(princ y1)
> (prompt "\nX2 = ")(princ x2)
> (prompt "\nY2 = ")(princ y2)
> (prompt "\nX3 = ")(princ x3)
> (prompt "\nY3 = ")(princ y3)
> (prompt "\nX4 = ")(princ x4)
> (prompt "\nY4 = ")(princ y4)
> (prompt "\nIntersection = ")(princ answerx)(princ answery)
> (command "-text" sp1 "" "" "kip1")
> (command "-text" ep1 "" "" "kpi2")
> (command "-text" sp2 "" "" "kip3")
> (command "-text" ep2 "" "" "kip4")
> ) ; end of progn
> (prompt "\nEntity selected is not a line!")
> ) ; end of if
> (princ)
> ); end ll.lsp
> 
Message 13 of 20
Anonymous
in reply to: Anonymous

Uh, OK.

-Jason

"John Uhden" wrote in message
news:43404F007E70C772A45841F4940B6464@in.WebX.maYIadrTaRb...
> Uh, I think integers will do fine as well.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> --> mailto:juhden@cadlantic.com
> --> http://www.cadlantic.com
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
> FAX 732-528-1332
>
> "Jason Piercey" wrote in message
> news:D167847E4910EC10FCB39695F1493431@in.WebX.maYIadrTaRb...
> > Points need to be reals. i.e. (4.0 4.0 0.0)
> >
> > -Jason
>
>
>
Message 14 of 20
Anonymous
in reply to: Anonymous

The Z will come into functionality later on down the road. This is only the
first phase of the idea I have for this program. I am wanting to build more
functionality into it later, and am trying to keep doors open. Thanks for
all the help everyone. I have the prototype working and will post it for you
guys to play with when I get a bit more functionality built in.

Thomas D. Wooton
Southern Systems Inc.

"John Uhden" wrote in message
news:A6E83D2944B34AC38E9066C5FD8B162E@in.WebX.maYIadrTaRb...
> Just for your info, since it seems that you're not interested in any Z
> values, you could skip the Z component altogether, since the (distance)
> function will return the 2D distance if given only '(x y).
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> --> mailto:juhden@cadlantic.com
> --> http://www.cadlantic.com
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
> FAX 732-528-1332
>
> "Thomas D. Wooton" wrote in message
> news:E6394116B611AAB4159937A563C1FEBD@in.WebX.maYIadrTaRb...
> >
> > "Bobby Jones" wrote in message
> > news:295F86FC3FD3EC6239B65D06DA42EFB9@in.WebX.maYIadrTaRb...
> > > Thomas, could you post all of the code? Thanks.
> > > --
> > > Bobby C. Jones
> > > Dots & Parens living in harmony...
> > >
> > >
> > >
> >
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > ; kip.lsp
> > ; BY Thomas D. Wooton 10/07/01
> > ;
> *************************************************************************
> > ; *
> *
> > ; * Inputs kip loading numbers (Kilo/pounds) of weight distributed
> *
> > ; * over the specified supports. Start by selecting your conveyor path
> *
> > ; * (centerline of weight) and then your panel points (support
points).
> *
> > ; * next enter the average weight per foot. The program then generates
> *
> > ; * your kip loads and inputs them at the panel points.
> *
> > ; *
> *
> > ;
> *************************************************************************
> > ;
> > (DEFUN DTR (A)
> > (* PI (/ A 180.0))
> > )
> >
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; List line
> length
> > (defun C:LL (/ ENAME SP EP DIS)
> > ; screen prompts for info
> > (setq ENAME1 (entget (car (entsel "\nSelect Conveyor line: "))))
> > (setq ENAME2 (entget (car (entsel "\nSelect Support line: "))))
> > (setq lbs (getint "\nAverage Weight Per Foot "))
> > ; finding the x,y I need
> > (setq ETYPE1 (cdr (assoc 0 ENAME1)))
> > (setq SP1 (cdr (assoc 10 ENAME1)))
> > (setq EP1 (cdr (assoc 11 ENAME1)))
> > (setq x1 (car sp1))
> > (setq y1 (cadr sp1))
> > (setq x2 (car ep1))
> > (setq y2 (cadr ep1))
> > (setq ETYPE2 (cdr (assoc 0 ENAME2)))
> > (setq SP2 (cdr (assoc 10 ENAME2)))
> > (setq EP2 (cdr (assoc 11 ENAME2)))
> > (setq x3 (car sp2))
> > (setq y3 (cadr sp2))
> > (setq x4 (car ep2))
> > (setq y4 (cadr ep2))
> > (if (= ETYPE1 ETYPE2 "LINE")
> > (progn
> > ; calculates length of lines
> > (setq DIS1 (distance SP1 EP1))
> > (setq ANG1 (angle SP1 EP1))
> > (setq DIS2 (distance SP2 EP2))
> > (setq ANG2 (angle SP2 EP2))
> > ; calculates intersection of lines
> > ; I did not want to use the inters function because if they don't
> intersect I want it to error.
> > (setq ua (/ (- (* (- x4 x3) (- y1 y3)) (* (- y4 y3) (- x1 x3)))
> (- (* (- y4 y3) (- x2 x1)) (* (- x4 x3) (- y2 y1)))))
> > (setq answerx (+ x1 (* ua (- x2 x1))))
> > (setq answery (+ y1 (* ua (- y2 y1))))
> > ;
> > ;
> > ; Here is where I am wanting to take the x and y above and make a point
so
> > ; I can find the distance from this point to the start points and end
> points of each line.
> > ; If you draw two intersecting lines and run the routine you will get
the
> info
> > ; I have been able to extract and manipulate so far.
> > ; The intersection to end distance, divided by the total length, gives
me
> a percentage of
> > ; the total distance. Multiply this by your average weight, to find how
> much
> > ; weight is on each end of your supports. Ie your moment of inertia
> > ;
> > (setq d1 (list answerx answery 0))
> > ;
> > ;
> > ;
> > ;
> > ; calculates weight of each point
> > (setq kip1 (* (distance dis1 d1) lbs))
> > (setq kip2 (* (distance dis1 d1) lbs))
> > (setq kip3 (* (distance dis2 d1) lbs))
> > (setq kip4 (* (distance dis2 d1) lbs))
> > ; screen prompts
> > (prompt "\nDistance = ")(princ dis1)
> > (prompt "\nStart Point = ")(princ SP1)
> > (prompt "\nEnd Point = ")(princ EP1)
> > (prompt (strcat " Angle = " (angtos ANG1 0 4)))
> > (prompt (strcat "\nLength = " (rtos DIS1 4 4)))
> > (prompt "\nDistance = ")(princ dis2)
> > (prompt "\nStart Point = ")(princ SP2)
> > (prompt "\nEnd Point = ")(princ EP2)
> > (prompt (strcat "\nLength = " (rtos DIS2 4 4)))
> > (prompt "\nX1 = ")(princ x1)
> > (prompt "\nY1 = ")(princ y1)
> > (prompt "\nX2 = ")(princ x2)
> > (prompt "\nY2 = ")(princ y2)
> > (prompt "\nX3 = ")(princ x3)
> > (prompt "\nY3 = ")(princ y3)
> > (prompt "\nX4 = ")(princ x4)
> > (prompt "\nY4 = ")(princ y4)
> > (prompt "\nIntersection = ")(princ answerx)(princ answery)
> > (command "-text" sp1 "" "" "kip1")
> > (command "-text" ep1 "" "" "kpi2")
> > (command "-text" sp2 "" "" "kip3")
> > (command "-text" ep2 "" "" "kip4")
> > ) ; end of progn
> > (prompt "\nEntity selected is not a line!")
> > ) ; end of if
> > (princ)
> > ); end ll.lsp
> > 
>
>
Message 15 of 20
Anonymous
in reply to: Anonymous

Uh.
Message 16 of 20
Anonymous
in reply to: Anonymous

Is that a Tim Allen, "Uh!". I'm trying to come up with a Tim Allen'ish
"Uggh", as I hang my head in shame kind of a sound 🙂 Lacking that here's
a good Tim Allen line from a not so great Tim Allen movie that fits the
situation just as well, "Oh, darn."
--
Bobby C. Jones
Dots & Parens living in harmony...
Message 17 of 20
Anonymous
in reply to: Anonymous

If that (real vs. int) wasn't the problem, then what was? Or did I miss
that part of the conversation?

-Jason


"Bobby Jones" wrote in message
news:AF97B1ACD4A2DDE579F870F9C959D1C2@in.WebX.maYIadrTaRb...
> Is that a Tim Allen, "Uh!". I'm trying to come up with a Tim Allen'ish
> "Uggh", as I hang my head in shame kind of a sound 🙂 Lacking that
here's
> a good Tim Allen line from a not so great Tim Allen movie that fits the
> situation just as well, "Oh, darn."
> --
> Bobby C. Jones
> Dots & Parens living in harmony...
>
>
>
Message 18 of 20
Anonymous
in reply to: Anonymous

(setq DIS1 (distance SP1 EP1))
...
...
...
(setq d1 (list answerx answery 0))<--this is OK for a point list
...
...
...
(setq kip1 (* (distance dis1 d1) lbs))<--all these failed
(setq kip2 (* (distance dis1 d1) lbs))
(setq kip3 (* (distance dis2 d1) lbs))
(setq kip4 (* (distance dis2 d1) lbs))

The code bombed here as Marco pointed out because dis1 is a distance itself
and not a point. A point that I missed, pun intended 🙂
--
Bobby C. Jones
Dots & Parens living in harmony...
Message 19 of 20
Anonymous
in reply to: Anonymous

The point is that I have given two answers that
me seem corrected and educated but that they have
been completely ignored.

Marco


"Jason Piercey" ha scritto nel messaggio
news:922393FF3378D62CB96CB3F639CD6907@in.WebX.maYIadrTaRb...
> If that (real vs. int) wasn't the problem, then what was? Or did I miss
> that part of the conversation?
>
> -Jason
>
Message 20 of 20
Anonymous
in reply to: Anonymous

Your answer to my question was not ignored. You explained your answer to my
problem well, (I learned something) and I have since gotten it to work. I
appreciate your effors.

Thomas D. Wooton
Southern Systems Inc.


"Marc'Antonio Alessi" wrote in message
news:D8B78719FA7F0BD4E2A077A369DE4B6A@in.WebX.maYIadrTaRb...
> The point is that I have given two answers that
> me seem corrected and educated but that they have
> been completely ignored.
>
> Marco
>
>
> "Jason Piercey" ha scritto nel messaggio
> news:922393FF3378D62CB96CB3F639CD6907@in.WebX.maYIadrTaRb...
> > If that (real vs. int) wasn't the problem, then what was? Or did I miss
> > that part of the conversation?
> >
> > -Jason
> >
>
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost