Sheep Posted March 10, 2020 Share Posted March 10, 2020 (edited) SOLVED! I've made several line using (polar Point1 Ang Distance). How do i get assoc 10 and assoc 11 to work without selecting the lines. Or maybe a routine that can create a list (append) when a line is done so i can retrive assoc 10 and 11 later. FYI, the line making is in the (WHILE section so the routine will keep making lines. Thank you. Edited March 10, 2020 by Sheep Solved. Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 10, 2020 Share Posted March 10, 2020 (edited) Polar doesn't create lines. Polar give you the new point given an old point, angle, and distance. You create a line by doing (entmake (list '(0 . "LINE") (cons 10 startpt) (cons 11 endpt) ) ) In order to get, for example, the start point of the line, you can do (cdr (assoc 10 (entget <line entity>))). Or another easier way: (vlax-curve-GetStartPoint <line entity>) Similarly: (vlax-curve-GetEndPoint <line entity>) If you want entmake to return the entity name, use entmakex instead of entmake. Edited March 10, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 10, 2020 Author Share Posted March 10, 2020 (edited) 6 minutes ago, Jonathan Handojo said: Polar doesn't create lines. Polar give you the new point given an old point, angle, and distance. Forgot to insert (comand "LINE" Point1 Point2) sorry about that. I do not use entmake or entmakex to create line just plain command LINE. I've zero knowleadge on VLX. Can you provide the code without Vlx please. How do i append the list? Edited March 10, 2020 by Sheep Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 10, 2020 Share Posted March 10, 2020 I don't really recommend that practice because, especially since you're using the command in the while loop, it will slow AutoCAD down. Plus, if you don't set your object snap off, that point might snap to another point if there are other objects nearby. If you still insist, then you can insert the following lines right after your command line: (vlax-curve-GetStartPoint (entlast)) (vlax-curve-GetEndPoint (entlast)) Plus, to append to a list, I would do: (setq pts (cons (list startpt endpt) pts)) And at the end of your while loop, do: (setq pts (reverse pts)) 1 Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 10, 2020 Share Posted March 10, 2020 (edited) Next question, if you create the line by (command "LINE" pt1 pt2), that means you already have the points pt1 and pt2, so why do the above and bother with assoc 10 and 11? Edited March 10, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 10, 2020 Author Share Posted March 10, 2020 (edited) @Jonathan Handojo, i know my code will fail but how to do i conenct the line from the list? (command "LINE" '(tpListReverse)) SOLVED! Edited March 10, 2020 by Sheep Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 10, 2020 Author Share Posted March 10, 2020 (edited) 1 hour ago, Jonathan Handojo said: Next question, if you create the line by (command "LINE" pt1 pt2), that means you already have the points pt1 and pt2, so why do the above and bother with assoc 10 and 11? Yes you're right i do aware of point1 equals to assoc 10 and point2 equals to assoc 11. I'm still at learning stage and i'm trying to use assoc 10 and 11 so that i can understand how to use it next time. In this manner i'm trying to understand how to append a list > get it assoc 10 and 11 >and try to make lines from the list while i'm in the (WHILE). Edited March 10, 2020 by Sheep Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 10, 2020 Share Posted March 10, 2020 (edited) Assoc is simply a function to catch the first item within a list of lists, and returning that list. For instance, (setq lst (list '("one" 1 2 3) '("two" 4 5 6) '("three" 7 8 9) '("four" 10 11 12) ) ) If you run (assoc "two" lst), you'll get ("two" 4 5 6) The same is with an entity. If you run (entget <line entity>), entget returns a list of dotted pairs like: '( (0 . "LINE") (8 . "0") (10 3.0 6.0.0) (11 23.4 15.6 0.0) (62 . 1) ... and many more ) Which is why if you run (assoc 10 (entget <line>)), you'll get (10 3.0 6.0 0.0) Then (cdr) of that list is simply (3.0 6.0 0.0) denoting the start point. Edited March 10, 2020 by Jonathan Handojo 1 Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 10, 2020 Author Share Posted March 10, 2020 10 minutes ago, Jonathan Handojo said: Which is why if you run (assoc 10 (entget <line>)), you'll get (10 3.0 6.0 0.0) Then (cdr) of that list is simply (3.0 6.0 0.0) denoting the start point. Thank you @Jonathan Handojo for helping a noob. By using your previous tips, i managed to solved the issue. So, i consider this is SOLVED. Again thank you so much for your time. Can you recommend a good book to learn AutoLisp (not Vlx)? Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 10, 2020 Share Posted March 10, 2020 Ha, I wish I know of a good book myself, because no matter how excellent you are, you're always on the learning curve (even @Lee Mac). Though I'm nowhere near Lee Mac's level, I do know that humans are never perfect and there are bound to be bugs. For example, in his Bounding Box Reactor whereby if you run Undo after executing his BBRN command as the undo reactors are not considered. Because I'm very new to reactors, I can only learn slowly and found some vlr-undo-reactor function. I only came to learn AutoLISP through an online course, experience, and this forum. 1 Quote Link to comment Share on other sites More sharing options...
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.