Jump to content

LISP to explode dimensions in multiple AutoCAD drawings


BorisJ

Recommended Posts

Hi, 
I would appreciate if someone could help me with a lisp to explode all dimensions in multiple drawings in AutoCAD.

I know exploding dimensions is not the best, however I have to do it for this specific project and I have a lot of drawings.

 

Link to comment
Share on other sites

Give this a try .. welcome to CadTutor :)

(defun c:foo (/ a d el s)
  ;; RJP » 2020-05-18
  (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  (if (setq s (ssget "_X" '((0 . "DIMENSION"))))
    (foreach e (mapcar 'cadr (ssnamex s))
      (vlax-for	a (vla-item (vla-get-blocks d) (cdr (assoc 2 (setq el (entget e)))))
	(entmakex (append (entget (vlax-vla-object->ename a))
			  (list '(8 . "Busted_Dims") '(62 . 8) (assoc 410 el))
		  )
	)
      )
      ;; Entdel does not work on layouts
      (vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object e)))
    )
  )
  (foreach l a (vlax-put l 'lock -1))
  (princ)
)
(vl-load-com)

 

Edited by ronjonp
  • Like 4
Link to comment
Share on other sites

Posted at forums/Autodesk. It would be useful if people stated posting else where.

 

Question asked on other forum was are dims in "model" or layouts or both ? This impacts ssget "x" 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-explode-dimensions-in-multiple-autocad-drawings/td-p/9520250

Edited by BIGAL
Link to comment
Share on other sites

10 hours ago, BIGAL said:

Posted at forums/Autodesk. It would be useful if people stated posting else where.

 

OP mentioned multiple drawings in AutoCAD

i tested your script it's not working.

not sure putting ronjonp's routine in script. eg: "exdim.scr"?

 

p/s: i just realized vla-explode method does not support dimensions!! hat's off ronjonp's 👍

 

Edited by hanhphuc
Link to comment
Share on other sites

15 hours ago, hanhphuc said:

 

OP mentioned multiple drawings in AutoCAD

i tested your script it's not working.

not sure putting ronjonp's routine in script. eg: "exdim.scr"?

 

p/s: i just realized vla-explode method does not support dimensions!! hat's off ronjonp's 👍

 

Thanks! 🍻

Link to comment
Share on other sites

hanhphuc I did not test script like every one here time has a cost so just tested on a single open dwg just suggested something like that sequence could work. Using the lisp to do the work is more reliable.

Link to comment
Share on other sites

10 hours ago, BIGAL said:

hanhphuc I did not test script like every one here time has a cost so just tested on a single open dwg just suggested something like that sequence could work. Using the lisp to do the work is more reliable.

 

no worries Al, just play around a bit neither my attempt working.

AFAIK script looks like entering command line, every space counts.

it seems easy writing script but clueless

 

my attempt was putting a standard command like your example as well as Ronjonp's code in xpdim.lsp 

(defun xpdim ( / ss )
  (setvar 'qaflags 1)
  (if
    (setq ss (ssget "_X" '((0 . "DIMENSION"))))
    (vl-cmdf "_explode" ss "")
  )
  (setvar 'qaflags 0)
  (princ)
)

 

then i wrote this script, test.scr

all put in path folder D:/TEMP/

open "D:/TEMP/TEST1.dwg" (load "D:/TEMP/xpdim.lsp") (c:foo) qsave close
open "D:/TEMP/TEST2.dwg" (load "D:/TEMP/xpdim.lsp") (xpdim) qsave close
open "D:/TEMP/TEST3.dwg" (load "D:/TEMP/xpdim.lsp") (c:foo) qsave close 

command: SCR 

 

Only the 1st TEST1.dwg (c:foo) worked , but it failed in the next drawing

error shows:

  Unable to find requested file: "qsave.dwg"

p/s: using BCAD 

 

 

 

 

Link to comment
Share on other sites

Put the qsave close in the lisp. Can not remember if need space after (load …)

 

I use dir *.dwg /b >dirlist

The use word using replace ^p to add all the correct commands before or after the end of line. Copy and paste to notepad the final as word has a nastyadding hidden characters even if saving as text.

Replace ^p open ^p

Replace ^p  (load "D:/TEMP/xpdim.lsp")^p

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