Jump to content

Change linetype for all block inside AutoCAD drawing


Irem Kocabas

Recommended Posts

Hello everyone.

I don't know how to do Lisp so I wanted to consult you. I use a lisp called ColorX that literally saved my life. Is there a version of this lisp that works with linetype logic? 

 

Link to comment
Share on other sites

There are many LISPs out there and many versions of them, are you able to post the ColorX lisp or a link to it so we know what it does?

Link to comment
Share on other sites

Why don't you have a go always a good time to learn.

 

At the heart of the code, is the change object property.

	     (vl-catch-all-apply 'vla-put-ExtensionLineColor (list Obj Color))
	     (vl-catch-all-apply 'vla-put-TextColor (list Obj Color))
	     (vl-catch-all-apply 'vla-put-DimensionLineColor (list Obj Color))

 

So if you look at the properties of an object using DUMPIT.lsp you should be able to work out correct Vla-put-property.

DumpIt.LSP

  • Like 1
Link to comment
Share on other sites

Just for the fun, i made a lisp wich change a linetype for all blocks.

(prompt (strcat "\nCopy and paste in command line: (command \"-LINETYPE\" \"?\" \"acadiso.lin\" \"\") to see all linetypes from \"acadiso.lin\" file.
Then from the column \"Name\" copy desire name of linetype and paste it in after execute \"CLTP\" command!
\nTo run a LISP type: CLTP"))
(princ)

(defun c:CLTP (/ ltype ename blk_name ss len i blk ent rtn etype obj)
  (setq ltype (getstring "\nEnter the linetype name:"))
  (princ)
  (if (not (tblsearch "LTYPE" ltype)) ;; if linetype doesn't exist, it will be loaded
    (progn
      (command "-LINETYPE" "L" ltype "acadiso.lin" "")
      (princ)
      )
    )
  (setq ename (car (entsel "\nSelect the desired block to change a linetype:")))
  (princ)
  (while (/= "INSERT" (cdr (assoc 0 (entget ename))))
    (prompt "\nSelected entitie is not a BLOCK! Try again...")
    (setq ename (car (entsel "\nSelect the desired block to change a linetype:")))
    (princ)
    )
  (setq blk_name (cdr (assoc 2 (entget ename))))
  (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 blk_name))))
  (setq len (sslength ss))
  (setq i 0)
  (while (< i len)
    (setq blk (cdr (assoc 2 (entget (ssname ss i)))))
    (if (setq ent (tblobjname "BLOCK" blk))
      (while (/= ent nil)
	(setq ent (entnext ent))
	(if (/= ent nil)
	  (setq rtn (cons ent rtn))
	  )
	)
      )
    (setq i (1+ i))
    )
  (setq i 0)
  (setq len (length rtn))
  (while (< i len)
    (setq etype (cdr (assoc 0 (entget (nth i rtn)))))
    (if (or (= etype "LINE") (= etype "CIRCLE") (= etype "ARC") (= etype "LWPOLYLINE"))
      (progn
	(setq obj (vlax-ename->vla-object (nth i rtn)))
	(vlax-put-property obj 'Linetype ltype)
	(entupd (nth i rtn))
	)
      )
    (setq i (1+ i))
    )
  (command "._regen")
  (princ)
  )

Best regards.

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