Jump to content

new boundary instead of the old object


samifox

Recommended Posts

hi

 

im trying to write a lisp that 

-ask user to select objects and capture them

- invoke the boundary command so user can pick point

- capture the new object generated

deletes the old objects

 

the lisp yell this error,

; error: bad argument type: VLA-OBJECT nil

i can't debug since the breakpoint is ignored. 

any idea? 

 

(defun c:br (/ original_objects new_boundary)
  (setq original_objects (ssget '((0 . "*LINE"))))
  (if (and original_objects (> (sslength original_objects) 0));; if selected
    (progn
      (command "-BOUNDARY")
      (setq new_boundary (entlast))
      
      (repeat (sslength original_objects)
        (vla-delete (vlax-ename->vla-object (ssname original_objects 0)))
      )
      (princ "\nBoundaries created and original polylines replaced.")
    )
    (princ "\nNo polylines found to replace.")
  )
  (princ)

 

 

 

 

 

Link to comment
Share on other sites

I've changed just slightly your code, but untested I think that it should work...

 

(defun c:br ( / original_objects new_boundary k e )
  (setq original_objects (ssget "_:L" (list (cons 0 "*LINE"))))
  (if (and original_objects (> (sslength original_objects) 0));; if selected
    (progn
      (initdia)
      (command "_.BOUNDARY")
      (while (< 0 (getvar (quote cmdactive)))
        (command "\\")
      )
      (setq new_boundary (entlast))
      (setq k -1)
      (repeat (sslength original_objects)
        (if (and (setq e (ssname original_objects (setq k (1+ k)))) (not (vlax-erased-p e)))
          (entdel e)
        )
      )
      (princ "\nBoundaries created and original polylines replaced.")
    )
    (princ "\nNo polylines found to replace.")
  )
  (princ)
)

 

HTH.

M.R.

Edited by marko_ribar
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...