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

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #60 on: February 17, 2024, 12:32:39 AM »
while the code below, for a Dwg that contains only a TEXT entity,
works normally ...
Code - Auto/Visual Lisp: [Select]
  1. (princ ". . . . . . . . . . . . . . . . . . . . . . . . . . . .")
  2. (princ "start")
  3. (setq el      (entlast)
  4.       egl     (entget el)
  5.       new-egl (subst (cons 1 "S U B S T") (assoc 1 egl) egl)
  6. )
  7. (entmod new-egl)
  8. (entupd el)
  9. (princ ". . . . . . . . . . . . . . . . . . . . . . . . . . . .")
  10. (princ "end")  
in ACCORECONSOLE
it doesn't work !
...
it seems to work ...
but it doesn't make any modification to the dwg !


...
if this is the true
(find some of my possible errors, please)
the question is :
what it is possible to do with ACCAORECONSOLE ?
« Last Edit: February 17, 2024, 12:42:43 AM by domenicomaria »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: DWG Batch Conversion with Lisp ?
« Reply #61 on: February 17, 2024, 03:13:36 AM »
This the reason I don't like Core Console...
Try Odbx with some limitation... It is fast...

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: DWG Batch Conversion with Lisp ?
« Reply #62 on: February 17, 2024, 12:08:04 PM »
F.W.I.W.

(getenv "DefaultFormatForSave")

Returns "64" which represents AutoCAD 2018 DWG format

in ac2023, 2024, 2025(beta)

Opening a drawing I save fron 2023 yesterday :

Code: [Select]
Opening an AutoCAD 2018 format file.
Regenerating model.
AutoCAD menu utilities loaded.
 KDUBToolsRibbon.mnl loaded . [Build 243:2023.05.25]
Autodesk DWG.  This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:

. . . just saying . .
Odbx save in same version of CAD used

JohnK

  • Administrator
  • Seagull
  • Posts: 10661
Re: DWG Batch Conversion with Lisp ?
« Reply #63 on: February 17, 2024, 01:27:55 PM »
I really wish you would state what you are trying to do using complete thoughts. It looks like you are trying to replace some text AND save a COPY of the drawing. In the thread I linked to I gave an updated text find and replace that I've used many times. A save as is easy to do. Using packages like dos_lib to parse a path string is unnecessary and probably not going to work in accoreconsole. You keep typing your hands with these odd snippets and then blame the tool.

ObjectDBX is just another method to use AutoCAD as the interface to update drawings. Doing so could lock up your PC and cause you to be unproductive during that time; using a smaller footprint process like accoreconsole is far better for production.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #64 on: February 17, 2024, 02:04:43 PM »
I really wish you would state what you are trying to do using complete thoughts. It looks like you are trying to replace some text AND save a COPY of the drawing. In the thread I linked to I gave an updated text find and replace that I've used many times. A save as is easy to do. Using packages like dos_lib to parse a path string is unnecessary and probably not going to work in accoreconsole. You keep typing your hands with these odd snippets and then blame the tool.
I don't blame ACCORECONSOLE ...

I am only trying to understand
what Is possibile to do with
ACCORECONSOLE

this is my complete and simple thought

but I saw that the ARX files cannot be loaded,
the VLA-XXX functions
and the VLAX-XXX functions do not work,
ENTMOD, ENTUPD and perhaps
ENTMAKE (this last function is not I've tested it yet)
they don't work...

and so I'm wondering what good can be done....

and it's certainly one more possibility...

because something can be done...

but I expected that they weren't there all these limitations
but
when I asked you if there were any LIMITATIONS...

when I asked you if EVERYTHING could be done,

you got angry and told me
to be clear and to say clearly that I didn't want your help...

but there is NO RELATIONSHIP
between the TWO THINGS...

if I write something it is only because
I try to understand something
and this means that anyone who helps me
to understand something is welcome...

...

there are no hidden thoughts,
hidden purposes but everything
is very simple...

have a nice day

JohnK

  • Administrator
  • Seagull
  • Posts: 10661
Re: DWG Batch Conversion with Lisp ?
« Reply #65 on: February 17, 2024, 02:43:22 PM »
`everything` you NEED or WANT? `Everything` is not a fair question because the answer invariably has to be NO because you cannot show dialog boxes, or draw AEC things, or use third party libraries like Python or probably dos_lib, or etc., etc..

If all you need to do is to save a copy of a file, make a PDF, find and replace text, etc. than you can most certinaly use accoreconsole. These are all things that do not NEED to use the VL* libraries.

I've used entmod.
https://www.theswamp.org/index.php?topic=4591.msg605179#msg605179

So, what does batch drawing conversion mean to YOU? Saving a copy, doing text replacement, and what? What VLX functions do you NEED?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #66 on: February 17, 2024, 02:59:09 PM »
`everything` you NEED or WANT? `Everything` is not a fair question because the answer invariably has to be NO because you cannot show dialog boxes, or draw AEC things, or use third party libraries like Python or probably dos_lib, or etc., etc..

If all you need to do is to save a copy of a file, make a PDF, find and replace text, etc. than you can most certinaly use accoreconsole. These are all things that do not NEED to use the VL* libraries.

I've used entmod.
https://www.theswamp.org/index.php?topic=4591.msg605179#msg605179

So, what does batch drawing conversion mean to YOU? Saving a copy, doing text replacement, and what? What VLX functions do you NEED?

Code - Auto/Visual Lisp: [Select]
  1. (setq el      (entlast)
  2.       egl     (entget el)
  3.       new-egl (subst (cons 1 "S U B S T") (assoc 1 egl) egl)
  4. )
  5. (entmod new-egl)
  6. (entupd el)
  7.  
Why doesn't this code work?
 ...
I have no special needs.

 I have already solved my problems.

 I'm just trying to understand something.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #67 on: February 17, 2024, 04:21:36 PM »
Quote
Code - Auto/Visual Lisp: [Select]
  1. (setq el      (entlast)
  2.       egl     (entget el)
  3.       new-egl (subst (cons 1 "S U B S T") (assoc 1 egl) egl)
  4. )
  5. (entmod new-egl)
  6. (entupd el)
  7.  
Why doesn't this code work?

That is probably the stupidest test I can imagine for ACCORECONSOLE.

There are several elements to a test.
establist your goals,
write the code,
is the code logically correct,
is the code syntactically correct,
does the code load,
does the code run,
does the code act as expected,
is it error free,
is it safe,
are there side effects,
is it performant,
etc . .

To my mind you have failed the first and third elements of the procedure.
What are the chances that opening a random drawing and executing (entlast) will return an entity that has a dxf key of 1 ??
and that the entity is the one you wanted to modify.


I'm suggesting that you put your time into doing some reading on the issues mentioned in this thread,
rather than pollute the space with incomplete thoughts and questions disguised as statements.

This is a peer to peer forum and anyone reading these posts in the future is going to be more confused at the the end that they may have been at the start.

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: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #68 on: February 17, 2024, 11:16:12 PM »
To my mind you have failed the first and third elements of the procedure.
What are the chances that opening a random drawing and executing (entlast) will return an entity that has a dxf key of 1 ??
and that the entity is the one you wanted to modify.

I did the test on three drawings that contain only 1 entity. and this entity is a text.
(and I already explained this in previous posts)
I tested the script (i.e. simple lisp code and it works fine without any problem)


There are several elements to a test.
-establist your goals,

my gol is discover what is possible to do with accoreconsole,  because i don't know it
and to test something that I don't know I begin from simple and little things

write the code (it has been done)
is the code logically correct, (I think so... it's very simple)
is the code syntactically correct, (I think so... it's very simple)
does the code load, yes ...
does the code run, yes ...
does the code act as expected, i tested it as "normal" lisp before and it works fine
is it error free, (I think so... it's very simple)
is it safe, (I think so... it's very simple)
are there side effects, (... side effects certainly not dangerous ...)
is it performant, (it is a secondary aspect in this simple case)


. . . trying to know something you don't know
and doing tests starting from small and simple things,
is it stupid ?

I do not agree !

I think it's smart !


rather than pollute the space
with incomplete thoughts
and questions disguised as statements


I honestly don't understand the meaning of these statements
and the reasons for the rude tone

This is a peer to peer forum and anyone reading these posts
in the future is going to be more confused
at the end than they may have been at the start.


to clarify it is necessary to understand the simple things first ...
... I don't know accoreconsole ...
... and I did some small tests, very simple ...
... the small steps help to understand bigger things ...
... and I think this contributes to the clarity...
« Last Edit: February 18, 2024, 01:53:23 AM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #69 on: February 18, 2024, 12:18:40 AM »
What are the chances that opening a random drawing and executing (entlast) will return an entity that has a dxf key of 1 ??
and that the entity is the one you wanted to modify.

this image (which has already been posted by me)...
shows what happens while ACCORECONSOLE is active
(  c:\windows\system32\cmd.exe  )


What are the chances that opening a random drawing ... (100% ... it is not a random drawing)

and as you can see (for drawings that contain only 1 entity and that is a TEXT)
it finds the entity of TEXT type ,
extracts the list with ENTGET,
modifies the list with SUBST, ...

... but even if everything seems to work,
at the end the result is that
the drawing is not modified ...
....
... basically nothing happens...

... this is what I'm trying to understand...

« Last Edit: February 18, 2024, 02:22:49 AM by domenicomaria »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: DWG Batch Conversion with Lisp ?
« Reply #70 on: February 18, 2024, 04:29:06 AM »
WorksforMe

Code - Auto/Visual Lisp: [Select]
  1.         ( (lambda ( / )
  2.                 (setq   el      (entlast)
  3.                                 egl     (entget el)
  4.                                 new-egl (subst (cons 1 "S U B S T") (assoc 1 egl) egl)
  5.                 )
  6.                 (entmod new-egl)
  7.                 (entupd el)
  8.                 (command "_qsave")
  9.                   ;; save
  10.                  
  11.             (princ)
  12.           )
  13.    )
  14.  

Quote
----------------------------------------x- 2024/02/18 -x------
Batch command: "D:\BatchingScriptFiles\BatchDrawings_accoreconsole.bat" D:\BatchingScriptFiles\Drawing101.dwg
Started at 2024/02/18 22:26:54.43
    "C:\Program Files\Autodesk\AutoCAD 2023\accoreconsole.exe" /i "D:\BatchingScriptFiles\Drawing101.dwg" /s "D:\BatchingScriptFiles\BatchDrawings_accoreconsole.scr" /l en-US
Ended at 2024/02/18 22:26:55.34


So I have no idea why it doesn't work for you.
Unless you are doing something different than advised.


« Last Edit: February 18, 2024, 04:33:45 AM by kdub_nz »
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: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #71 on: February 18, 2024, 05:41:23 AM »
@kdub_nz

I'll believe you if you tell me it works!

that's what I want to hear,
because this means that it is possible to do many things
with Accoreconsole...
...
I didn't put it in my script
(command "_qsave") !
(and this is what you should have told me from the first moment)

And it was "slightly" necessary!

But still I can't get it to work.

It seems like everything is fine
looking at the CMD.exe window
but when I open the 3 drawings on which I do the test
nothing has changed.

There is something important
which escapes me even now!

If I find out what it is I'll let you know!

Thank you
« Last Edit: February 18, 2024, 05:45:39 AM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #72 on: February 18, 2024, 06:25:21 AM »
Code - Auto/Visual Lisp: [Select]
  1. (setq el      (entlast)
  2.       egl     (entget el)
  3.       new-egl (subst (cons 1 "AAAAAAAA") (assoc 1 egl) egl)
  4. )
  5. (princ (assoc 1 egl) )
  6. (entmod new-egl)
  7. (entupd el)
  8. (setq p1 (list 0 0 0) p2 (list 99 99 99) )
  9. (entmakex (list '(0 . "LINE") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbLine") (cons 10 p1) (cons 11 p2) ) )
  10. (command "_qsave")

take a look to the
cmd.exe window

I tested also entmakex to draw a line...

And it seems everything goes well
(there is also qsave !)

But at the end
nothing happens !

And the tested files are NOT read only !
« Last Edit: February 18, 2024, 06:51:57 AM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: DWG Batch Conversion with Lisp ?
« Reply #73 on: February 18, 2024, 10:14:47 AM »
and in any case in reality I didn't forget to add to the script
(command "_qsave")
because I had taken it for granted that the changes made to the drawing
by accoreconsole were stored ...
(certainly I reasoned badly also because I don't know accoreconsole)
...
but I still can't get it to work
(also adding to the script (command "_qsave") )
...

JohnK

  • Administrator
  • Seagull
  • Posts: 10661
Re: DWG Batch Conversion with Lisp ?
« Reply #74 on: February 18, 2024, 01:07:48 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).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org