Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
arulanand12
Posts: 32
Registered: ‎04-01-2008
Message 11 of 28 (2,167 Views)

Re: Batch convert DGN to DWG

04-01-2012 11:25 PM in reply to: arulanand12

Thanks for the LISP. I will post my feedback later after running it.

Distinguished Contributor
mmoolhuysen
Posts: 159
Registered: ‎08-26-2003
Message 12 of 28 (2,161 Views)

Re: Batch convert DGN to DWG

04-02-2012 01:09 AM in reply to: arulanand12

I didn't implemented any mapping setup in my lisp file. If you need this, you should insert it as the 4th parameter of the DGNIMPORT command, in other words, replace the last pair of double quotes with the name of the mapping setup prepared in the defauld startup drawing.

Active Contributor
arulanand12
Posts: 32
Registered: ‎04-01-2008
Message 13 of 28 (2,148 Views)

Re: Batch convert DGN to DWG

04-02-2012 08:17 PM in reply to: mmoolhuysen

DGN files have external links for title blocks. I have put all these external linked files in the same folder where input DGN files are. But the LISP loop is breaking when it looks for the external link. Is it possible to locate it from within LISP? I would appreciate your help.

Distinguished Contributor
mmoolhuysen
Posts: 159
Registered: ‎08-26-2003
Message 14 of 28 (2,136 Views)

Re: Batch convert DGN to DWG

04-03-2012 09:35 AM in reply to: arulanand12

The setting to include references can't be changed with command line version of DGNIMPORT. However, it can be set by  in the dialogue box of the the regular DGNIMPORT command. I suspect that the stetting is saved in the registry, because it persist from drawing session to drawing session, and that last property is good news for us.

 

So, as a workaround to change things towards a behavior as desired by you, try this:

Import one random DGN-file using the regular DGNIMPORT command. In the dialogue box, look for a framed section named External DGN references, in there, select the radio button in front of option Translate references to blocks or xrefs. Allow the import to proceed by clicking on the OK button.

 

After this, I've opened a new drawing and run the LISP routine I've posted before, and now it did include the references.

 

With friendly greetings, Manfred.

Member
ddotten
Posts: 4
Registered: ‎12-21-2011
Message 15 of 28 (2,101 Views)

Re: Batch convert DGN to DWG

04-13-2012 12:05 PM in reply to: arulanand12

Thank you for the lisp file.  However, I have not been able to perform a DGNIMPORT with 2012.  I have been able to run the command in 2011.  Could you advise me as to how to modify the lisp routine to be compatible with 2011?  

Distinguished Contributor
mmoolhuysen
Posts: 159
Registered: ‎08-26-2003
Message 16 of 28 (2,079 Views)

Re: Batch convert DGN to DWG

04-16-2012 05:11 AM in reply to: ddotten

We haven't installed version 2011, so you will have to do some testing yourself:

  1. Type -DGNIMPORT (dash in front of command name) at the command line prompt, to see what options this command expects without the use of a dialogue box.
  2. I believe system variable DGNIMPORTMODE does not exist yet in version 2011, so you have to drop the line (setvar "DGNIMPORTMODE" 1). I do not know if standard behavior of DGNIMPORT in version 2011 is to import into the existing drawing or always create a new drawing (this is controlled by the setting of system variable DGNIMPORTMODE in version 2012)
Member
ddotten
Posts: 4
Registered: ‎12-21-2011
Message 17 of 28 (2,077 Views)

Re: Batch convert DGN to DWG

04-16-2012 05:33 AM in reply to: arulanand12

I did remove the line (setvar "DGNIMPORTMODE" 1) as 2011 does not have that variable.  And 2011 does open a new drawing.  

 

In an attempt to run down the problem I changed the variables from LOCAL to GLOBAL.  I then loaded the LISP and executed the DGNI command.  I received error: bad argument type: FILE nil.  I then queried variables tx1-tx4 and they were correct.  However tx5 returns "nil" as does the variable fil.  

Distinguished Contributor
mmoolhuysen
Posts: 159
Registered: ‎08-26-2003
Message 18 of 28 (2,071 Views)

Re: Batch convert DGN to DWG

04-16-2012 05:58 AM in reply to: ddotten

Variable fil staying nil suggests that line  (setq fil (open tx1 "r") was not successfully executed.

  1. Please check if variable tx1 holds the correct filename inclusive path for the txt file containing the names of the drawings you want to convert.
  2. You're not able to re-open the file because a previous run of the routine did come to the point it supposed to close the file at line (close fil) or was not able to close it properly.
Member
ddotten
Posts: 4
Registered: ‎12-21-2011
Message 19 of 28 (2,038 Views)

Re: Batch convert DGN to DWG

04-19-2012 07:52 AM in reply to: mmoolhuysen

I have solved the "fil variable problem" of the LISP.  (I had included the file path in my DGNConvertList)

I begin in Drawing1.  I load the LISP and type the DGNI command.  AutoCAD opens the 1st dgn "TopoA" in Drawing2.  The program stops with the dgn displayed.  If I toggle back to Drawing1 then the LISP continues and the Drawing1 is saved as a TopoA.dwg.  It then proceeds to open the 2nd dgn "TopoB" in Drawing3 and once again the program stops.  If I once again toggle back to the original drawing whose name is now TopoA, the process resumes.  This continues until the last dgn has been opened.  It has saved the dgns as dwgs in the target folder, but I have to manually switch each time a dgn is imported.

 

Member
ddotten
Posts: 4
Registered: ‎12-21-2011
Message 20 of 28 (2,033 Views)

Re: Batch convert DGN to DWG

04-19-2012 08:38 AM in reply to: ddotten

I have solved the "fil variable problem" of the LISP.  (I had included the file path in my DGNConvertList)

The problem now is that in AutoCAD 2011 the DGNIMPORT command opens a new drawing each time.  

 

I begin in Drawing1.  I load the LISP and type the DGNI command.  AutoCAD opens the 1st dgn "TopoA" in Drawing2.  The program stops with the dgn displayed.  If I toggle back to Drawing1 (or close Drawing2) then the LISP continues and the Drawing1 is saved as a TopoA.dwg.  It then proceeds to open the 2nd dgn "TopoB" in Drawing3 and once again the program stops.  If I once again toggle back to the original drawing whose name is now TopoA (or close Drawing3), the process resumes.  This continues until the last dgn has been opened.  It has saved the dgns as dwgs in the target folder, but I have to manually switch each time a dgn is imported.

 

Is there a routine or command that I can insert into the LISP to return AutoCAD to the original drawing to allow the process to continue?

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community