I need a simple lisp that explodes dimensions, leaders and multileaders

I need a simple lisp that explodes dimensions, leaders and multileaders

Anonymous
Not applicable
3,834 Views
21 Replies
Message 1 of 22

I need a simple lisp that explodes dimensions, leaders and multileaders

Anonymous
Not applicable

I'm seriously about to pull my hair out. 

Before anyone says anything about how bad it is to explode dimensions...

Yes, I know. I preach this.

 

I need it nonetheless. I have to scale 15,000 files in half and convert them to tiffs. The tiff part is simple & the rest of my script works and there is a lot to my script.

 

They have all types of drawing that are different units and they are scaled in model space, which is also ridiculous. They also have a billion different dimension styles. I only need this for model space.

 

So please please please can someone help me with this. It doesn't seem like this should be that hard. I'm basically begging for help.

 

I have tried so many things that I have to reach out. 

 

Thank you in advance for saving my hair and my mind, because I'm losing it.

0 Likes
Accepted solutions (2)
3,835 Views
21 Replies
Replies (21)
Message 2 of 22

hak_vz
Advisor
Advisor

Hope this will help you save some hair. Function unlocks all locked layers and explodes all dimension objects. On similar principle thaw/freeze layers could be included if needed by deleting comment sign ";".  You may call it directly from your script or as a command exd.

 

(defun explode_dimensions ()
;unlocks all layers and explodes all visible dimension objects;
(setvar "cmdecho" 0)
(command "-layer" "unlock" "*" "")
;(command "-layer" "thaw" "*" "") (command "explode" (ssget "X" '((0 . "DIMENSION,LEADER,MLEADER"))) "") (setvar "cmdecho" 1) (princ "\nDone") (princ) )
(defun c:exd()(explode_dimensions))

 

 


Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 22

ВeekeeCZ
Consultant
Consultant

It doesn't work, isn't it?

 


@hak_vz wrote:

 

(defun explode_dimensions ()
;unlocks all layers and explodes all visible dimension objects;
(setvar 'ctab "Model") (setvar "cmdecho" 0) (command "-layer" "unlock" "*" "")
;(command "-layer" "thaw" "*" "")
(initcommandversion) (command "explode" (ssget "X" '((0 . "DIMENSION,LEADER,MULTILEADER"))) "") (setvar "cmdecho" 1) (princ "\nDone") (princ) )
(defun c:exd()(explode_dimensions))

 

 



 

0 Likes
Message 4 of 22

hak_vz
Advisor
Advisor
@ВeekeeCZ  Ok, you have edited this code to work with newer versions of Acad. My version is so old that it doesn't have Multileader object, so my guess for 0 type was wrong (I was to leazy to check it online). It also doesn't have (initcommandversion).  Ok selecting model space is ok, i didn't included it since @Anonymous  will use it only in model space, and I personaly rarely step out of model space. Now, I hope that he uses newer versions that support all this "new" stuff otherwise your intervention wont work. And as in the fairy tales, someone else collects the price.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 22

ВeekeeCZ
Consultant
Consultant

I thought that my issue with the code was that lisp version of EXPLODE does not handle multiple objects by default. 

In older versions needs to be set QAFLAGS to 1 to make it work.

0 Likes
Message 6 of 22

Anonymous
Not applicable

Thank you so much for your response.

 

I don't actually know lisp I was just hoping that somebody had something just laying around that I could use. When I do a search mostly it's half answered or it's just people chastising the person who asks on how bad it is to explode dimensions. I've literally never had this problem before I had to figure something out like this.

 

Keep in mind that when I type this all out in the keyboard it works just fine but when I do it through my script...nothin. turns out the dinensions do seem to all be on 1 layer, but i'm not completely sure of this as there's no way that I could open 15,000 files. And...most of the drawings don't seem to have dimensions .

 

I've frozen all my layers except for the dimension and then I do an explode all via command line & it works fine. My script however, doesn't work when I do this. Hmmm, I just had an idea. But...I don't have faith that it will work either, I'll still try it. 

0 Likes
Message 7 of 22

ВeekeeCZ
Consultant
Consultant

This works. 

0 Likes
Message 8 of 22

Anonymous
Not applicable

Oh wow, I replied only to the comment above my response. I apologize for that. Y'all are awesome. I haven't checked this yet BeeKeeCZ. But I will here shortly. I just downloaded your zip. 

 

Man, I am so grateful to all of you for helping. Thank you so much.

0 Likes
Message 9 of 22

Jonathan3891
Advisor
Advisor

I worked for a place not that long ago that wanted all dimensions exploded, it was a nightmare.

 

(defun c:xdims (/ s)
  (command "._undo" "_begin")
  (setvar 'cmdecho 0)
  (foreach tab (append '("Model") (layoutlist))
    (setvar 'ctab tab)
    (if	(setq s (ssget "_X" (list '(0 . "*DIM*") (cons 410 tab))))
      (foreach x (mapcar 'cadr (ssnamex s)) (command "_.explode" x))
    )
  )
  (command "._undo" "end")
  (setvar 'cmdecho 1)
  (princ)
)

Jonathan Norton
Blog | Linkedin
0 Likes
Message 10 of 22

Anonymous
Not applicable

OMG!!! I LOVE LOVE LOVE YOU, BeeKeeCZ! *sigh in relief* *Hugs you so big* 

I mean, I don't even have to select anything or put an 'ALL' in there.  I never thought that I'd be actually happy about exploding dimensions.

Message 11 of 22

Anonymous
Not applicable

This isn't bad either, except that it doesn't explode mleaders and it switches to Layout1. I'd have to add an extra line in my script to switch it back. Either way, I truly appreciate the help.

0 Likes
Message 12 of 22

ВeekeeCZ
Consultant
Consultant

I guess we all here love to see happy users! Especially those who know what they're doing.

 

To be fair, my part is just those few red fixes. All the rest belongs to @hak_vz 

 

Message 13 of 22

ronjonp
Mentor
Mentor

Another train of thought that leaves less of a mess ... instead of exploding you could put all items in modelspace in a block then scale by 1/2 from '(0. 0. 0.).

 

Why do you need to do this scaling to create a tif?

0 Likes
Message 14 of 22

Anonymous
Not applicable

It's for another companies program that they have to take the TIFFs and plug them into their software.  I had done the 15K 3 times for 3 different languages, using scripts to scrub the drawings for each language aka layers & blocks, in reality ir was 45, 000 files. I was able to do 5,000 at a time with 5 acad sessions open. I have a beast of a computer & it worked beautifully. I then popped em into DocuFreezer and converted them to TIFFs. (Highly recommend Docufreezer)  These were initially done at 1:1, and converted them to 800 DPI. They were too big for them so on their side they scaled them down by half and changed the DPI to 600. 

 

Here's the kicker. Their program uses the vector data from the drawings (which btw, I had to extract the callout bubble locations for all 15K files (only had to do this from 1 set of the 15k files as language doesn't matter for that). Well...needless to say my data wouldn't fit anymore because of their TIFF scaling. So...now I have to scale them all by 1/2 and recreate the TIFFS. Since all of the drawings have already been scrubbed this was much faster...except of course for the dimensions. So now I have to recreate the TIFFs at 1/2 size w/600 DPI and extract my callout bubble from the initial 15K the drawings again so that it fits.  But I do have 2 recreate the tiffs on all 3 languages AGAIN.

This is nuts, but it's working. 

 

So this little LISP routine has saved my insanity & time. This isn't bad, except for sheer volume of files. 

0 Likes
Message 15 of 22

ronjonp
Mentor
Mentor
Accepted solution

That sounds insane! 🙂 So my block idea with scaling down 1/2 would not work? I was thinking of this route because it could be automated using object DBX which is waaayyyyy faster than scripting. Come to think of it core console might help you as well since all the cores on your computer can be used.

 

If you need help making this even less tedious, I might be able to help out.

0 Likes
Message 16 of 22

Anonymous
Not applicable

Talk about not seeing the forest through the trees... I didn't read your entire comment before. But... your idea changed everything. I did open each dwg thru the script & then made the whole thing a block, scaled it by 1/2 and changed the ltscale. BeeKeeCZ's lisp worked but only if the dims were already exploded. It would stop my script if they were. Now, it works like buttah. 

 

Having said that, I'd really like to pick your brain about the core thing. I have a 12 core AMD threadripper processor. I am using a different  script generator. For now, I only had to do 50 of them. But over the weekend is when the sludge of all this happens. So...if you don't mind, I'll hit you up on Sunday. No pressure, but I'd really appreciate the brain picking.

Regardless, thanks so much for jump starting my brain.

0 Likes
Message 17 of 22

hak_vz
Advisor
Advisor

@Anonymous wrote:

It's for another companies program that they have to take the TIFFs and plug them into their software. 


Those TIFFs will be used for printing out or just for screen presentation? If its not for printing then even 600 dpi is way to much.

 


@Anonymous wrote:

Well...needless to say my data wouldn't fit anymore because of their TIFF scaling. So...now I have to scale them all by 1/2 and recreate the TIFFS.


Why not rescale the data?

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 18 of 22

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Anonymous wrote:

..BeeKeeCZ's lisp worked but only if the dims were NOT already exploded. It would stop my script if they were. Now, it works like buttah. 

...


Not sure I follow... (sorry for my limited language skills)

I guess you meant that the routine does stop your script when there are no dims to explode left. I should fix this before... It's a minor issue worth fixing even if you decide to follow a different and better solution. btw good luck with that.

 

(defun c:ExplodeDims (/ ss)

  (if (setq ss (ssget "_A" (list '(0 . "DIMENSION,*LEADER") '(410 . "Model"))))
    (progn
      ;(command "-layer" "unlock" "*" "")  	;uncomment if needed
      ;(command "-layer" "thaw" "*" "")		;uncomment ff needed
      (setvar 'ctab "Model")
      (initcommandversion)
      (command "_.explode" ss "")))
  (princ)
  )
0 Likes
Message 19 of 22

Anonymous
Not applicable

BeeKeeCZ, this is still an awesome tool! & thank you even more for fixing it. I'm still going to add it to my stuff.  As far as I'm concerned, you have great skills, you're the bee's knees! Pun intended. 😊 Thank you so much!!!

 

 

 

0 Likes
Message 20 of 22

Anonymous
Not applicable

No, they aren't for presentation. This is hard to explain. They use those tiffs and plug them into another program that is used as a catalog of sorts. They take my data and plug the tiffs in (they may convert these into SVGs I'm not sure about this part though, all I know is my task) at my x,y coordinates. I still have to do both.  

 

The reason I have to make them again is because I scale the drawing at 0,0 and when they scaled their they were at the extents of the TIFFs and they used the corner of the TIFF which us some random point. The TIFFs have no title block so it's too the extents of the geometry so it's a random point because I had strip the titleblock from the dwgs.

 

The way the drawings were made was archaic & amateur.  They did the whole scaling of the titleblock thing in model space. Makes me want to slap people. Hahah

0 Likes