Author Topic: DWG Batch Conversion with Lisp ?  (Read 4816 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 733
Re: DWG Batch Conversion with Lisp ?
« Reply #75 on: February 18, 2024, 01:52:02 PM »
Without looking at the code (I didn't get past the part where you use ENTLAST to--hopefully--get a text item. My guess is that you have the drawing open in AutoCAD when you try to modify the drawing in accoreconsole (thus open the file with accoreconsole in readonly).
NOT hopefully--get a text item
but certainly get a text item,
because the drawings on which I did the tests
contain only one entity... and it is obviously a TEXT !

My guess is that you have the drawing open in AutoCAD when you try to modify the drawing in accoreconsole
absolutely NOT...
I am aware that if a file is open in one application
it cannot be opened in write mode by another application...

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2154
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #76 on: February 18, 2024, 01:55:29 PM »
@

I shouldn't HAVE to tell you anything
. . particularly that you SHOULD save the drawing after you make changes to it if you want the changes to be sustained.

just stop and think before you blame me for not telling you.


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

domenicomaria

  • Swamp Rat
  • Posts: 733
Re: DWG Batch Conversion with Lisp ?
« Reply #77 on: February 18, 2024, 02:07:27 PM »
@

I shouldn't HAVE to tell you anything
. . particularly that you SHOULD save the drawing after you make changes to it if you want the changes to be sustained.

just stop and think before you blame me for not telling you.
I don't blame you for not telling me!

It was a serious oversight on my part...

Partly due to the fact that I thought that the changes made by Accoreconsole
were stored anyway and therefore there was nothing to save.

But it was the wrong reasoning of a person
who does not know how Accoreconsole works.

That is probably the stupidest test I can imagine for ACCORECONSOLE.
What are the chances that opening a random drawing and executing (entlast)
will return an entity that has a dxf key of 1 ??


But before you, very kindly, tell me that what I proposed is
the stupidest test you've ever seen...
... try reading the other posts FIRST
where I had already explained that
I was doing the tests on drawings containing a single entity
and that this was a TEXT
... so the chances to get a text entity with ENTLAST are 100% !

... But you haven't read these posts ...
... and you told me that the my test is
the stupidest you've ever seen...
...
and you also suggested that
before writing something,
it would be good for me
to first read what was written in previous posts...

And yours is certainly the right advice.

And it applies to everyone.


For you too.
« Last Edit: February 18, 2024, 02:17:16 PM by domenicomaria »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2154
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #78 on: February 18, 2024, 02:26:52 PM »
You are correct.
That wasn't the stupidist code I've seen.

It was impolite of me to say so.

I shan't do it again.

//-

On my signature I used to have
"  Everything will work just as you expect it to, unless your expectations are incorrect.  "

Perhaps I should have said that.


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

JohnK

  • Administrator
  • Seagull
  • Posts: 10665
Re: DWG Batch Conversion with Lisp ?
« Reply #79 on: February 18, 2024, 03:48:22 PM »
Does my find and replace routine work?

Guess:
kdub seemed to use my batch script; maybe it’s your batch scrip that’s not loading the right script?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2154
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #80 on: February 18, 2024, 04:22:43 PM »
Does my find and replace routine work?

Guess:
kdub seemed to use my batch script; maybe it’s your batch scrip that’s not loading the right script?

Yes John, I used your .bat and a suitably modified .scr.
It worked nicely.

I haven't used accc for years.
Have used ScriptPro

Before that I used  an app I hacked together long, long ago.
I'd like to see ScriptPro rejuvinated for ac2025.

// back to the issue at hand :
I believe that the original goal of cleaning up and saving drawings could be achieved nicely using your batcher ( with a suitable script file).

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

domenicomaria

  • Swamp Rat
  • Posts: 733
Re: DWG Batch Conversion with Lisp ?
« Reply #81 on: February 19, 2024, 04:35:51 AM »
maybe it’s your batch scrip that’s not loading the right script?
I understand that you are not addressing me... but to remove any doubt...
« Last Edit: February 19, 2024, 05:27:13 AM by domenicomaria »

JohnK

  • Administrator
  • Seagull
  • Posts: 10665
Re: DWG Batch Conversion with Lisp ?
« Reply #82 on: February 19, 2024, 10:53:08 AM »
Does my find and replace routine work?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 733
Re: DWG Batch Conversion with Lisp ?
« Reply #83 on: February 19, 2024, 02:09:02 PM »
Does my find and replace routine work?

yes

it works

but qsave however fails allways !

I also tried saving the files in Autocad 2000 format
to see if for some reason qsave would work

but he never saves what he does

I didn't add it to the end of the script...
...but now even if I did it, nothing has changed!

And the files are NOT read only !

And are NOT open in another application or in Acad



kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2154
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #84 on: February 19, 2024, 07:55:10 PM »
Works for me.

Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( / )
  2.         (setq el      (entlast)
  3.           egl     (entget el)
  4.           new-egl (subst (cons 1 "AAAAAAAA") (assoc 1 egl) egl)
  5.         )
  6.         (princ (assoc 1 egl) )
  7.         (entmod new-egl)
  8.         (entupd el)
  9.         (setq p1 (list 0 0 0) p2 (list 99 99 99) )
  10.         (entmakex (list '(0 . "LINE") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbLine") (cons 10 p1) (cons 11 p2) ) )
  11.         (command "_qsave")
  12.                   (princ)
  13. ))
  14.  
  15.  

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

JohnK

  • Administrator
  • Seagull
  • Posts: 10665
Re: DWG Batch Conversion with Lisp ?
« Reply #85 on: February 19, 2024, 08:16:38 PM »
I've got you to eliminate a few possibilities and now I'm thinking it might be a difference in your batch script and mine (kdub has no problems and neither does anyone else who's used my batch script) and the only difference between yours and mine--besides the for loop stuff--is that I specifiy a language. Try to add the language flag when you call acccoreconsole: "/l en-US".

Not the greatest test but let's roll with it. Try the <DOT> before the qsave to see if that helps.

Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( / el tel)
  2.     (setq el (entget (entlast)))
  3.     (setq tel (entmod
  4.                 (subst
  5.                   (cons 1 "abc...")
  6.                   (assoc 1 el)
  7.                   el)))
  8.     (if (tel)
  9.       (princ "\n----> PASS!")                   ; -If entmod didnt return nil.
  10.       (progn                                    ; -Start printing some information
  11.         (princ "\n *ERROR* Faild to entmod")
  12.         (princ (strcat
  13.                  "\nThe current text is: "
  14.                  (assoc 1 (entget (entlast))))) ;; Have no idea if `entlast` will work
  15.         )
  16.       )
  17.     (command "_.qsave")
  18.     )
  19.  )
  20.  



My batch script should have the ability to be called from AutoLisp and tomorrow, when I get in front of a computer with AutoCAD, I will test it out.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2154
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #86 on: February 19, 2024, 08:22:13 PM »
Hi John,
Perhaps add a Pause statement into the 'FAIL' block.

The ac command line whips past pretty damn quickly  :wink:


//---

I've noticed Dan is back from the jungle and playing with this too  :)
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8836
  • AKA Daniel
Re: DWG Batch Conversion with Lisp ?
« Reply #87 on: February 19, 2024, 08:28:28 PM »
I've noticed Dan is back from the jungle and playing with this too  :)

LOL, washing all the bat poop off my clothes, didn’t see any pythons though.

JohnK

  • Administrator
  • Seagull
  • Posts: 10665
Re: DWG Batch Conversion with Lisp ?
« Reply #88 on: February 19, 2024, 08:37:52 PM »
Kerry, I just open a command prompt, or powershell, and open accoreconsole to do my testing.
Something like: "C:\Program Files\Autodesk\AutoCAD 2023\accoreconsole.exe /i D:\BatchingScriptFiles\Drawing101.dwg /l en-US"
should open the drawing like you would in AutoCAD. Then the drawing wont close and you can hack away.

If you want to load your script, you can use something like below (I think I remember that LOAD works because that's how you can load ARXs).
(load "D:\\BatchingScriptFiles\\BatchDrawings_accoreconsole.scr")

...
Pythons?! Bleh! I saw a gardner snake last summer and my family still won't let me live it down.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 733
Re: DWG Batch Conversion with Lisp ?
« Reply #89 on: February 19, 2024, 11:46:29 PM »
Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( / el tel)
  2.     (setq el (entget (entlast)))
  3.     (setq tel (entmod
  4.                 (subst
  5.                   (cons 1 "abc...")
  6.                   (assoc 1 el)
  7.                   el)))
  8.     (if (tel)
  9.       (princ "\n----> PASS!")                   ; -If entmod didnt return nil.
  10.       (progn                                    ; -Start printing some information
  11.         (princ "\n *ERROR* Faild to entmod")
  12.         (princ (strcat
  13.                  "\nThe current text is: "
  14.                  (assoc 1 (entget (entlast))))) ;; Have no idea if `entlast` will work
  15.         )
  16.       )
  17.     (command "_.qsave")
  18.     )
  19.  )
  20.  

As "normal" lisp, it works well ... (with entlast too)
even it says :  "extra cdrs in dotted pair on input"

but as script for accoreconsole still doesn't save anything !