Jump to content

Recommended Posts

Posted

How do I insert a newly created object using command syntax (in my case, I used boundary command) into a variable in AutoLISP?

Posted

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))

 

 

Posted

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?
image.thumb.png.d5338cc45a05f87ab9e008373267544e.png

Posted

My try:

(defun c:pp()
  (command "boundary" pause "")
  (command "move" (entlast) "" (list 10 0) "")
  )

 

Posted (edited)

Still does not work...
It's like the command boundary and command move entlast execute at the same time

Edited by Aditya Bagaskara
Posted

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?)

Posted (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?

 

image.thumb.png.de53ebe821e27f5880d601a2a360de0b.png

Edited by Aditya Bagaskara
Posted
3 minutes ago, fuccaro said:

Glad to read you did it! :)

Thanks for helping :)

  • Like 1
Posted
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!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...