Page 1 of 1

Alter .lsp to work with icad?

Posted: Sat Jul 24, 2021 10:41 pm
by rhgrafix
Can anyone fine tune this to work in IntelliCAD? It works great in Autocad. It's for imprinting multiple entities onto 3d solid faces. Thanks! - Quan?

Code: Select all

(defun c:mulimp (/ a ans b itm num ss ss1)
  (if (and (princ "\nSelect a 3D solid or surface: ")
	   (setq ss (ssget "_+.:E:S:L" '((0 . "3DSOLID,*SURFACE"))))
	   (princ "\nSelect objects to imprint: ")
	   (setq ss1 (ssget "_:L" '((0 . "ARC,CIRCLE,LINE,*POLYLINE,ELLIPSE,SPLINE,REGION,3DSOLID"))))
	   (progn
	     (initget "Y N")
	     (setq ans (cond ((getkword "\nDelete entities? [N Y] <N>: "))
			     ("N")
		       )
	     )
	   )
      )
    (progn
      (setq itm	0
	    num	(sslength ss1)
      )
      (command "_.imprint" (setq a (ssname ss 0)))
      (while (< itm num)
	(if (not (eq a (setq b (ssname ss1 itm))))
	  (command b (strcat "_" ans))
	)
	(setq itm (1+ itm))
      )
      (command "")
    )
  )
  (princ)
)
; with Y or N choice
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/imprint-multiple-objects/td-p/5496030

Re: Alter .lsp to work with icad?

Posted: Sun Jul 25, 2021 1:36 am
by QuanNguyen
Hi Hamm,

In the IntelliCAD, we can use the command "SolidEdit" to imprint an object to a solid object.
refer this routine:

Code: Select all

(defun c:imp (/ ans ent sol)
  (if (and (setq sol (car (entsel "\nSelect a 3D solid or surface: ")))
	   (princ "\nSelect objects to imprint: ")
	   (setq ent (car (entsel "\nSelect a object to imprint: ")))
	   (progn
	     (initget "Y N")
	     (setq ans (cond ((getkword "\nDelete entities? [N Y] <N>: "))
			     ("N")
		       )
	     )
	   )
      )
    (progn      
      (command "_.solidedit" "body" "imprint" sol ent ans "exit" "exit")      
    )
  )
  (princ)
)

Re: Alter .lsp to work with icad?

Posted: Sun Jul 25, 2021 1:38 pm
by rhgrafix
Quan,
I think that the thing that is missing is a while loop, what I need to do is select multiple entities to imprint at one time like my original code.
Do you know how to make the original code work in IntelliCAD?
Thanks much,
Ramon

Re: Alter .lsp to work with icad?

Posted: Mon Jul 26, 2021 1:51 am
by QuanNguyen
Try this:

Code: Select all

(defun c:imps (/ ans ent itm sol ss)
	(if (and (setq sol (car (entsel "\nSelect a 3D solid or surface: ")))
			(princ "\nSelect objects to imprint: ")
			(setq ss (ssget  '((0 . "ARC,CIRCLE,LINE,*POLYLINE,ELLIPSE,SPLINE,REGION,3DSOLID"))))
			(progn
				(initget "Y N")
				(setq ans (cond ((getkword "\nDelete entities? [N Y] <N>: ")) ("N") ) ) )
		)
		(progn
			(setq itm	0)
			(while (< itm (sslength ss))
				(if (not (eq sol (setq ent (ssname ss itm))))
					(command "_.solidedit" "body" "imprint" sol ent ans "exit" "exit")	)
				(setq itm (1+ itm))
			)
		)
    )
	(princ))

Re: Alter .lsp to work with icad?

Posted: Mon Jul 26, 2021 7:50 pm
by rhgrafix
Thank you Quan!
That works perfectly, I don't know how you do it.
Ramon :O)