Jump to content

Pass selected objects along commands


samifox

Recommended Posts

hi

 

I'm developing a script that employs built-in commands such as "flatten," "overkill," and "convert." Each of these commands yields different objects as output. Consequently, I find myself continually needing to select these output objects as they are passed between commands.

i want to use the user function (SelectObjectsWithinClosedShape) to select the outputted polylines after each command , i want to use it as a variable. 

 

what im doing wrong?

 

(defun c:Demo()
  
  (SelectObjectsWithinClosedShape) ;; selects and highlight all objects inside the shape
  (command "-overkill"  "Done") ;; suppose they are selected, -overkill can operate on them
  
 (SelectObjectsWithinClosedShape) ;; selects and highlight all objects inside the shape
  
  (command "flatten" "done")
  
 (SelectObjectsWithinClosedShape) ;; selects and highlight all objects inside the shape
  
  (Convert2Polyline);; user defined function

  (repeat 3
    (command "Join" )
	(SelectObjectsWithinClosedShape) ;; selects and highlight all objects inside the shape
  )

 (SelectObjectsWithinClosedShape) ;; selects and highlight all objects inside the shape
  
  (simplify) ;; a user function that simpliplify selected polylines
  )

 

 

Edited by samifox
Link to comment
Share on other sites

  • samifox changed the title to Pass selected objects along commands

So when these commands are executed the old entity's are "changed or modified" and new entity's are created. This is bad :(  because they change entity names and are no longer part of a selection set you used in the command. BUT when things are added or modified they are added at the end of internal list in the drawing file. this means you can set a place holder and then select all entity's after it to reacquire the new/modified entity's after the command.

 

(setq LastEnt (entlast)) ;set this before any command that edits/modifies/or creates entity's
(setq SS1 (ssadd)) ;you either need a blank selection set or an existing one to put the new entity's into

(command "flatten" SS "")

(while (setq LastEnt (entnext LastEnt)) ;collect all entitys at the end of the drawing list.
  (ssadd LastEnt SS1) 
)
;entity's created after LastEnt are now in selection set SS1

 

Edited by mhupp
Link to comment
Share on other sites

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