Michaels Posted August 8, 2010 Author Posted August 8, 2010 (defun c:try (/ p1 p2 p3 p4 plst) ;Define function, Declare local variables (setq p1 (getpoint "\nSpecify First Point : ") ;Get point 1 p2 (getpoint "\nSpecify Second Point : ") ;Get point 2 p3 (getpoint "\nSpecify Third Point : ") ;Get point 3 p4 (getpoint "\nSpecify Fourth Point : ")) ;Get point 4 (setq [color="red"]plst[/color] (list p1 p2 p3 p4)) ;Place all the points in a list call plst (Polyline plst) ;Go to the Polyline function using the supplied list plst (princ) ;Exit quietly ) ;End defun (defun Polyline ([color="red"] lst [/color]) ;Polyline function, lst is the argument you are feeding plst to (entmakex ;Entity Make (list ;List (cons 0 "POLYLINE") ;Entity type 3D polyline (cons 10 '(0 0 0)) ;Dummy point XYZ ) ;End list ) ;End entmakex (mapcar ;Returns a list that is the result of executing a function with a list (or lists) ;supplied as arguments to the function (function ;Tells the Visual LISP™ compiler to link and optimize an argument as ;if it were a built-in function (lambda ([color="red"] p [/color]) ;Defines an anonymous function (entmake ;Entmake (list ;List (cons 0 "VERTEX") ;Polyline vertex (cons 10 [color="red"]p[/color]) ;Polyline points ) ;End list ) ;End entmake ) ;End lambda ) ;End function [color="red"] lst [/color] ;lst ) ;End mapcar (entmakex ;Entmake (list ;List (cons 0 "SEQEND") ;Sequence End ) ;End list ) ;End make ) ;End defun I have a question about the list. Why the list is divided into two which is lst and p ? I mean why it's not complete ? Thanks Quote
The Buzzard Posted August 8, 2010 Posted August 8, 2010 I am using plst as a variable containing the list of points from p1 p2 p3 & p4 to pass on to feed lst which is used as the argument. Notice that plst is declared as a local variable, But since lst is used as an argument, You do not need to declare it. In some cases you may use multiple arguments which can have direct values or values passed to variables which are then passed on to the arguments. I believe Lee can explain it better to you, But you need to study up on this to get a better understanding especially when making entmake codes. This is very important. Quote
The Buzzard Posted August 8, 2010 Posted August 8, 2010 In this statement, Polyline is the function and plst is the variable containing the values to pass on to lst the argument. (Polyline plst) ;Go to the Polyline function using the supplied list plst Quote
The Buzzard Posted August 8, 2010 Posted August 8, 2010 If you remove plst from your declared local variables, (defun C:TRY (/ p1 p2 p3 p4 plst) ;Remove plst here. Make sure you save the program and reloaded it. Run the program as you normally would again. After the program has run. Then at the command prompt type: !PLST, It will return a list similar to the one below. These are the values that are being sent to the argument lst. Command: !PLST ((2.16387 5.70183 0.0) (5.00249 5.65626 0.0) (2.59707 4.48291 0.0) (5.4243 4.23229 0.0)) You can put plst back when done. This was only being to done to test the values of the variables so you can see what they contain. When variables are declared they lose there values when the program completes as not to interfere with other programs containing variables that are similar. Quote
Michaels Posted August 8, 2010 Author Posted August 8, 2010 Yes. That's right. ( local variables) (defun Polyline ( lst ) (entmakex (list (cons 0 "POLYLINE") (cons 10 '(0 0 0)) ) ) (mapcar (function (lambda ( p ) (entmake (list (cons 0 "VERTEX") (cons 10 p))) ) ) lst ) (entmakex (list (cons 0 "SEQEND"))) ) So Please correct my answer if something was wrong ? In the above entmakex , the mapcar would distribute the plst values to the p and the lambda would build the points from first point (p1) until the forth one (p4) on (cons 10 p) by lst , and the defun is ready afterall with the points to insert, when the (Polyline plst) is called after selecting the points and are value with IF function ? Things like Selection set looping ... Waw ..... long distance Hope this correct or at least 99% of it ? Many thanks Quote
The Buzzard Posted August 8, 2010 Posted August 8, 2010 Yes. That's right. ( local variables) (defun Polyline ( lst ) (entmakex (list (cons 0 "POLYLINE") (cons 10 '(0 0 0)) ) ) (mapcar (function (lambda ( p ) (entmake (list (cons 0 "VERTEX") (cons 10 p))) ) ) lst ) (entmakex (list (cons 0 "SEQEND"))) ) So Please correct my answer if something was wrong ? In the above entmakex , the mapcar would distribute the plst values to the p and the lambda would build the points from first point (p1) until the forth one (p4) on (cons 10 p) by lst , and the defun is ready afterall with the points to insert, when the (Polyline plst) is called after selecting the points and are value with IF function ? Things like Selection set looping ... Waw ..... long distance Hope this correct or at least 99% of it ? Many thanks You somewhat got the idea. Lambda again defines an anonymous function and mapcar returns a list of that executing function. Keep cracking at it and the idea will sink in. Quote
Michaels Posted August 8, 2010 Author Posted August 8, 2010 Thanks Buzzard, I am getting close to it, and not only cracking it. it's a matter of fighting with it .. so I have to win. last question Please. Why the following tow codes seems to me as if they are Goal Keepers in Playground !. (entmake (list [color="red"](cons 0 "VERTEX")[/color] (cons 10 p))) ) ) lst ) (entmakex (list [color="red"](cons 0 "SEQEND")[/color])) I mean what is the meaning of Vertex and Seqend ? As I know Vertex is the knot grip of a polyline. But it comes with cons as a name of entity ? And as you have mentioned Seqend is a Sequence. Is it the playground or the ring that points would run inside of it only with out an exit ? My best regards, Quote
Tharwat Posted August 8, 2010 Posted August 8, 2010 Thanks Buzzard,I am getting close to it, and not only cracking it. it's a matter of fighting with it .. so I have to win. last question Please. Why the following tow codes seems to me as if they are Goal Keepers in Playground !. (entmake (list [color="red"](cons 0 "VERTEX")[/color] (cons 10 p))) ) ) lst ) (entmakex (list [color="red"](cons 0 "SEQEND")[/color])) I mean what is the meaning of Vertex and Seqend ? As I know Vertex is the knot grip of a polyline. But it comes with cons as a name of entity ? And as you have mentioned Seqend is a Sequence. Is it the playground or the ring that points would run inside of it only with out an exit ? My best regards, Here is the answer of your questions that earlier explained by following the member. For a Polyline, we must entmake(x) each separate VERTEX entity in succession and then entmake a terminating SEQEND entity to declare that we have finished constructing the Polyline. Also Thanks for BUZZARD for the hard work . Regards, Quote
Lee Mac Posted August 8, 2010 Posted August 8, 2010 Michaels I think you need to go back through this thread and read all the posts more thoroughly - people are devoting their time to try to help you understand, it's the least you could do in return. Quote
Michaels Posted August 8, 2010 Author Posted August 8, 2010 Michaels I think you need to go back through this thread and read all the posts more thoroughly - people are devoting their time to try to help you understand, it's the least you could do in return. Thank you, That's exactly what I have been doing all over these days. Also great thanks for Buzzard for his hard work for me. Finally to tharwat313 for his honest answer to give the right to writer. Now things are better to me with LWPolyline and Polyline . Michaels Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.