DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

batch convert problems

Started by Leo Ratschbacher, December 24, 2014, 04:43:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leo Ratschbacher

We do 2D -CAD drawings for traffic accident reconstruction.
(visit: www.autoview.at/en/autoview )
Drawings are produced using AutoCAD software, as a good
number of our clients use DESIGNCAD (in different versions)
we convert the DWG files to DCD fileformat.
We used the function  [batch convert]
We have done that with DesignCAD 2D pro:
this software allows only one level of grouping,
which is not sufficient for our needs.

We did it with DesignCAD 3D max vers. 17 and
found out, that the pathspecifications in the convert.dbx
files do not overrule the paths specified in extra/options/paths.
So we had to puzzle the converted files to the correct directories by hand.

We tried to do the conversion with DesignCAD 3D max vers. 22
worked fine in the beginning, but the SIZE of the converted drawingfile
sums up with each new drawing - so the last of 600 files ended up
with 78 MB instead of 90 kB !!!

Tried to do the job with macro import/export but DesignCAD
does not open or saveas with filenames in a list....

So we are VERY thankful for hints to do the job properly.

Files to convert are AutoCAD R14 dwg (1998), 5 different layers, 2 to 3 levels of grouping
z-coordinate = 0, no complex structures,patterns or symbols

Santa regards from Austria (no snow so far!!)

Leo

Juergen

#1
Hi Leo,

welcome, nice to meet you here!

QuoteWe tried to do the conversion with DesignCAD 3D max vers. 22
Tried to do the job with macro import/export but DesignCAD
does not open or saveas with filenames in a list....

Be sure, here are many experts for this topic in this forum ...
The analysis and traceability of the problem is certainly easier in case
you publish the script you are using right now.

Christmas Greetings to Austria,

Juergen

Leo Ratschbacher

Hello Juergen,

thanks for the hint.
We were very disapointed, that DC v22
didn't do the batch convert function properly, so we didn't
put much effort in Macro tests.
But I shall post the script to the forum..
best regards
Leo

Juergen

#3
Hi Leo,

my BasicCad knowledge is very limited, in the forum are other people with much more experience about this topic.
Consider this snippet and give it a try.

'
' dwgtodcd.d3m -- jürgen -- been tested with DWG\GRUND\BMW
'
target$="converted_dcd_files"
' Didn't find a DC makedir command
c$ = "cmd.exe /c "+chr$(34)+"md "+target$+chr$(34)
run c$

'build file list
File$ = "files.txt"
c$ = "cmd.exe /c "+chr$(34)+"dir *.dwg /b > "+File$+chr$(34)
run c$
'Next statement only to prevent locked File$, get some time
message "Click 'OK' to start DWG to DCD conversion"
sys(36)=2
' Units
sys(1100)=6
sys(1101)=6
sys(1102)=6

open "i", 1, File$
' Loop all dwgs
   do while eof(1) = 0
   input #1, dwg$

' Opens dwg source
>DwgIn 'Check the options!
{
  <Filename [dwg$]
  <ExplodeBlocks 1
  <SkipHatch 0
  <SkipLayouts 0
  <UseVectorFont 0
  <ImportPointmark 1
  <ImportGenericDimensions 0
  <ImportVaryingWidthAsSingleWidth 0
  }

' Fit drawing
>fittowindow
{
}

'Select entire drawing
>SelectAll
{
}

dcd$=target$+"\"+LEFT$(dwg$, len(dwg$)-3) + "dcd"

>SaveAs
{
<Filename [dcd$]
}

'delete current drawing
>Erase
{
}
loop
Close 1
sys(36)=0
'delete file list
c$ = "cmd.exe /c "+chr$(34)+"erase "+File$+chr$(34)
run c$
'Here we are
message "Find converted files in folder: "+target$

End


Copy the code in a file called dwgtodcd.d3m. Copy dwgtodcd.d3m in a folder with the source dwg (e.g. DWG\GRUND\BMW)
and start the macro. You'll find the converted dcd files in the subfolder 'converted_dcd_files'. The file sizes don't
look so bad ...


Kind regards,

Juergen

PS: Remember DCC doesn't need dcd-format anymore ;)

prl

#4
Like Juergen, I have a brute-force routine available too, but it will require you to create the file list by issuing a DOS command.

Example: 

v:\dir /b /s *.dxf >files.txt

will give a full path list of all DXF files on the V:\ drive in this format:

V:\CFM Details\6A.dxf
V:\CFM Details\6AA.DXF
V:\CFM Details\6B.dxf
V:\CFM Details\6C.dxf
V:\CFM Details\6D.dxf
V:\CFM Details\6E.dxf
V:\CFM Details\6F.dxf
V:\CFM Details\6G.dxf
V:\CFM Details\6H.dxf
V:\CFM Details\6I.dxf
V:\CFM Details\6J.dxf
V:\CFM Details\6K.dxf
V:\CFM Details\6L.dxf
V:\CFM Details\6M.dxf
V:\CFM Details\6N.dxf
V:\CFM Details\6O.dxf
V:\CFM Details\6P.dxf
.
.
.



Then feed the files.txt to the bdxfin.d3m routine.  The routine will read and load the dxf and create a DesignCAD file in the same folder/directory as the original dxf.

'Program: bdxfin.d3m (batch in and convert dxf files from a file list)

a$="v:\Files.txt" 'ensure this program knows where to find the list.

open "i", 1, a$
Do While Eof(1) = 0
   
   >New
   {
   }
   
   if (NOT Sys(344)) then
      >2DMode
      {
      }
   endif
   
   Input #1, dwg$
   
   if dwg$ = " " then End
 
   >DxfIn
   {
   <Filename [dwg$]
   }

  total=len(dwg$)
  outfile$=left$(dwg$,total-4) 'strip extension from drawing name
  outfile$=outfile$+".dcd"

  >fittowindow
  {
  }

  >close
   {
   <SaveChanges 1
   <Filename [outfile$]
   }
Loop

sys(1)=0
End


Juergen

#5
Hi Leo,
Hi Prl,

@Leo: Prl is right as always! Using > new leads to smaller dcd-files.
The consequence is that the processing of the macro is substantially longer.
However, I think the smaller files have higher priority.

Converted Files are scaled for drawing units in meter.

Considering Prl's script you find enclosed a new approach. I guess your folder
structure is looking like this:

DWG
..Front
..Grund
..Heck
..Seite

etc.

Place this script as dwgtodcd.d3m in the root of DWG (or Front, or Grund... etc) and
execute the macro. This will last veeeeeery long as for each model a new drawing is
opened (and closed). I guess this can take hours. You'll find the dcd files in a subfolder
of each make (converted_dcd_files).

Give it a try.

Kind regards,

Juergen


'
' dwgtodcd.d3m -- jürgen -- been tested with DWG\GRUND\
'
target$="converted_dcd_files"

Folders$ = "folders.txt"
c$ = "cmd.exe /c "+chr$(34)+"dir /s /b /o:n /ad > "+Folders$+chr$(34)

run c$
'Next statement only to prevent locked Folder$, get some time
message "Caught all folders. Click 'OK'"

'make folders

open "i", 1, Folders$
' Loop all dwg folders and create dcd folders
   do while eof(1) = 0
input #1, foldername$
c$ = "cmd.exe /c "+chr$(34)+"md "+foldername$+"\"+target$+chr$(34)

run c$

loop
close 1

'build file list
File$ = "files.txt"
c$ = "cmd.exe /c "+chr$(34)+"dir /s /b *.dwg > "+File$+chr$(34)
run c$

'Next statement only to prevent locked File$, get some time
message "Click 'OK' to start DWG to DCD conversion"
'sys(36)=2 'uncomment in case previews not required (faster)
' Units
sys(1100)=6
sys(1101)=6
sys(1102)=6

open "i", 1, File$
' Loop all dwgs
   do while eof(1) = 0
     
   >New
   {
   }
   input #1, dwg$
' Opens dwg source
>DwgIn 'Check the options!
{
  <Filename [dwg$]
  <ExplodeBlocks 1
  <SkipHatch 0
  <SkipLayouts 0
  <UseVectorFont 0
  <ImportPointmark 1
  <ImportGenericDimensions 0
  <ImportVaryingWidthAsSingleWidth 0
  }

' Fit drawing
>fittowindow
{
}

'Select entire drawing
'>SelectAll
'{
'}

dcd$=LEFT$(dwg$, len(dwg$)-3) + "dcd"
Z=len(dcd$)
find$=dcd$
possum=0
for i=z to 1 step -1
'poslast=pos
pos = INSTR(find$,"\")
possum=possum+pos
if pos=0 then goto ready 'bad, bad bad ...
find$=RIGHT$(find$, len(find$)-pos)
'poslast=pos
next i
ready:

rr$=left$(dcd$,possum)+target$+"\"+right$(dcd$,z-possum)
dcd$= rr$

>SaveAs
{
<Filename [dcd$]
}

'delete current drawing
'>Erase
'{
'}
  >close
   {
   }
loop
Close 1
sys(36)=0
'delete file list
c$ = "cmd.exe /c "+chr$(34)+"erase "+File$+chr$(34)
run c$
'delete folder list
c$ = "cmd.exe /c "+chr$(34)+"erase "+Folders$+chr$(34)
run c$
'Here we are
message "Find converted files in vehicle make subfolder: "+target$

End