Jump to content

Help lisp move object to at vertex polyline?


tuantrinhdp

Recommended Posts

Hello everyone.
I have object, i want to auto copy and move it to at vertex polyline. 
Please help me create lisp. 
Thanks for your help.

 Capture.png

TEST.dwg

Link to comment
Share on other sites

First make the red circle and hatch into a block with the insertion point in the center.

This will ask you to Select a Block. Next Select entities: this can be one or multiple polylines you wish to place the selected block around.

 

;;----------------------------------------------------------------------;;
;; COPY B TO EACH VERTICY OF POLYLINE
(defun C:FOO (/ blk SS e ent coords)
  (setvar 'cmdecho 0)
  (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block"))))))
  (prompt "\nSelect Polyline")
  (if (setq SS (ssget ":L" '((0 . "*POLYLINE"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq coords (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)))) (entget ent))))
      (foreach pt coords
        (vl-cmdf "_insert" blkname "_non" pt "" "" "")
      )
    )
  )
  (setvar 'cmdecho 1)
  (princ)
)

 

Edited by mhupp
Code Updated
  • Thanks 1
Link to comment
Share on other sites

49 minutes ago, mhupp said:

First make the red circle and hatch into a block with the insertion point in the center.

This will ask you to Select a Block. Next Select entities: this can be one or multiple polylines you wish to place the selected block around.

 

;;----------------------------------------------------------------------;;
;; COPY BLOCK TO EACH VERTICY OF POLYLINE
(defun C:FOO (/ blkname SS ent coords pt)
  (setvar 'cmdecho 0)
  (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block"))))))
  (if (setq SS (ssget ":L" '((0 . "*POLYLINE"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq coords (vl-remove-if 'not (mapcar (lambda (p) (if (= 10 (car p)) (cdr p))) (entget ent))))
      (foreach pt coords
        (vl-cmdf "_insert" blkname "_non" pt "" "" "")
      )
    )
  )
  (setvar 'cmdecho 1)
  (princ)
)

 

Thank you, but have error: bad function: #<SUBR @00000204b652d2c8 -lambda-> 

Link to comment
Share on other sites

Try This

 

(defun Circle (cen rad)
	(entmakex 
		(list 
			(cons 0 "CIRCLE") 
			(cons 10 cen) 
			(cons 40 rad)
			(cons 8 "Dot")
		)
	)
)

(defun c:dot ( / e g f)
(command "_.Layer" "_Make" "Dot" "_Color" "1" "" "LType" "Continuous" "" "")
(setq e (entsel "\nPlease choose an object: "))

  (setq e (entget (car e)))
  (foreach f e
    (if	(= (car f) 10)
      (progn
	(setq g (list (cadr f) (caddr f)))
	(setq g (trans g 0 1))
	(Circle g 0.5)
	(command "_-hatch" "_S" "_L" "" "_LA" "Dot" "_P" "_S" "")

      )
    )
  )
)

 

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