Aditya Bagaskara Posted February 13 Posted February 13 How do I insert a newly created object using command syntax (in my case, I used boundary command) into a variable in AutoLISP? Quote
fuccaro Posted February 13 Posted February 13 If that's the last entity created by AutoCAD, it can be referred using ENTLAST. You can try it right in AutoCAD's command line. Enter say Move (entlast) "" 10 0 to move the last created entity with 10 units along Ox. For a more complicated scenario, you could name the graphic entities as you create them, say like this: .....create a circle here..... (setq myCircle (entlast)) ..... create a line..... (setq line1 (entlast)) .....create an other line..... (setq line2 (entlast)) ..... now you can access those entities by the names myCircle, line1, line2... You could change the layer of the first line: (entmod (subst '(8 . "LayerRED") (assoc 8 (setq elist (entget line1))) elist)) Quote
Aditya Bagaskara Posted February 13 Author Posted February 13 I tried previously with ENTLAST but it does not work. So I have this configuration of bigger rectangle and smaller rectangle created sequentially. I made a function that can execute boundary command and, like you said, confirm it with entlast, but the one that moves is the smaller rectangle because it is the lastly created object in AutoCAD, whereas I want to move the object created with AutoLISP instead. Do you know how to fix this? Quote
fuccaro Posted February 13 Posted February 13 My try: (defun c:pp() (command "boundary" pause "") (command "move" (entlast) "" (list 10 0) "") ) Quote
Aditya Bagaskara Posted February 13 Author Posted February 13 (edited) Still does not work... It's like the command boundary and command move entlast execute at the same time Edited February 13 by Aditya Bagaskara Quote
fuccaro Posted February 13 Posted February 13 Hm... I just tried it and it works on my computer. That's the reason I've put that "pause" there, to make the second instruction to wait the previous one to complete. As I said, it does work for me. Did you reload the lisp from the editor? does it report that the lisp was ok loaded?! If you copy/pasted the code, pay attention to the names: my program names PP, your is AA (or maybe AP?) Quote
Aditya Bagaskara Posted February 13 Author Posted February 13 (edited) I just did a workaround I recently found out that boundary command can be executed multiple times. So I set up a variable first rather than executing it directly in command syntax. What do you think? Edited February 13 by Aditya Bagaskara Quote
Aditya Bagaskara Posted February 13 Author Posted February 13 3 minutes ago, fuccaro said: Glad to read you did it! Thanks for helping 1 Quote
fuccaro Posted February 13 Posted February 13 7 hours ago, Aditya Bagaskara said: I just did a workaroundI Well, if it's not broken, then don't fix it. I just want to say that I tried on a different computer the code I posted above, and it worked fine. I wish you a nice day! 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.