Jump to content

help to correct exciting lisp code


hosyn

Recommended Posts

Hello guys

i m looking for a lisp code over the web for moving block perpendicularly on pline and found following:

(defun c:sto ( / en obj pts_ss ss_len c pten ptobj pted pt pt2)
 
 (setq en (ssget "_X" (list
            (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE")
            (cons 8 "A-WALL-INTR")
            ))
   )

 (princ "\nSelect Blocks: ")
 (setq pts_ss (ssget (list (cons 0 "INSERT"))))
 
(setq ss_len (sslength pts_ss))
 
(setq c 0)
 (while (< c ss_len)
   (setq pten (ssname pts_ss c))
   (setq ptobj (vlax-ename->vla-object pten))
   (setq pted (entget pten))
   (setq pt (cdr (assoc 10 pted)))

   (setq cnt 0)
   (while (< cnt (sslength en))
     (setq ename (ssname en cnt))
     (setq pt2 (vlax-curve-getClosestPointTo ename pt))
     (setq cnt (+ cnt 1))
     )
     
   (vla-move ptobj (vlax-3d-point pt) (vlax-3d-point pt2))
   (setq c (+ c 1))
   )
 
(princ)
 
)

 

unfortunately have slight error, please correct it anyone who can,we appreciate in advance gentleman.🙂

 

here this is error:

STO
Select Blocks:
Select objects: Specify opposite corner: 1 found
Select objects: Specify opposite corner: 0 found, 1 total
Select objects: 1 found, 2 total
Select objects: Specify opposite corner: 0 found, 2 total
Select objects:
error: bad argument type: lselsetp nil
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
Command:
Command:

 

Edited by hosyn
Link to comment
Share on other sites

AT THERE AFTER RUNNING COMMAND STILL THERE SOME ERROR INSTEAD CORRECT JOB.🤒

 

Edited by hosyn
Link to comment
Share on other sites

2 hours ago, dlanorh said:

This lisp has been "found" before. See Here

AT THERE AFTER RUNNING COMMAND STILL THERE SOME ERROR INSTEAD CORRECT JOB.🤒

Link to comment
Share on other sites

en variable is emtpy , and user still went ahead and select the block, that is why  (sslength en) will produce that error

 

  • You can remove "X" to enable the user to select on sceen
  • Make sure the selection is under the same layer listed as the filter
(setq en (ssget "X" ;<-- this for selection mode
     (list
            (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE")
            (cons 8 "A-WALL-INTR") ; <--- that layer name
            ))
   )

 

BTW: the lisp code is not that exciting at all 😁

 

 

Edited by pBe
  • Thanks 1
Link to comment
Share on other sites

:celebrate:this my fult in typing, i wanted to text  EXISTING CODE and auto-correct changed it.

Edited by hosyn
Link to comment
Share on other sites

31 minutes ago, pBe said:

en variable is emtpy , and user still went ahead and select the block, that is why  (sslength en) will produce that error

 

  • You can remove "X" to enable the user to select on sceen
  • Make sure the selection is under the same layer listed as the filter

(setq en (ssget "X" ;<-- this for selection mode
     (list
            (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE")
            (cons 8 "A-WALL-INTR") ; <--- that layer name
            ))
   )

 

BTW: the lisp code is not that exciting at all 😁

 

 

 

If I want changed it for closest existing pline someting like that:


(setq en (ssget "X" ;<-- this for selection mode
     (list
            (cons 0 "POLYLINE")  ;;;; <<<-----the nearest pline to any block
            (cons 8 "A-WALL-INTR") ; <--- that layer name
            ))
   )

 <<<-----the nearest pline to any block

HOW IT BE CHANGED?

Edited by hosyn
Link to comment
Share on other sites

43 minutes ago, hosyn said:

 

If I want changed it for closest existing pline someting like that:



(setq en (ssget "X" ;<-- this for selection mode
     (list
            (cons 0 "POLYLINE")  ;;;; <<<-----the nearest pline to any block
            (cons 8 "A-WALL-INTR") ; <--- that layer name
            ))
   )

 

 

 

First of all, the "X" at ssget filter will select absolutely all "POLYLINE" on the drawing, and i mean  ALL ,  I take it most it not all blocks are slightly off and you want an easy way to do it. and next you will be needing to align the blocks, etc..

 

I would suggest to go back to where the original code was "found"  and post you're request there. 

 

EDIT: I see that this requst is related to this, why not continue that thread instead of craeting a new one Hosyn? 

 

 

Edited by pBe
  • Thanks 1
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...