Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DGNIMPORTMODE AUTOCAD 2011

6 REPLIES 6
Reply
Message 1 of 7
JustinTCox
260 Views, 6 Replies

DGNIMPORTMODE AUTOCAD 2011

I am writing a LISP to import DGNs into a current drawing but every time it goes to run, it stops because AutoCAD opens the .dgn in a new drawing! appearently DGNIMPORTMODE allows you to change that option but I do not have that command in 2011. any ideas?

6 REPLIES 6
Message 2 of 7
hmsilva
in reply to: JustinTCox

Perhaps using a .scr file, to import the .dgn in a new dwg, save, close, insert the new .dwg at the current dwg...

 

HTH
Henrique

EESignature

Message 3 of 7
JustinTCox
in reply to: hmsilva

how can I use a script to dwgimport without it stopping the lisp or script?

Message 4 of 7
hmsilva
in reply to: JustinTCox

.scr file and
-dgnimport

EESignature

Message 5 of 7
JustinTCox
in reply to: hmsilva

when I use -dgnimport it opens the .dgn in a new window, therefor stops the script and lisp

Message 6 of 7
hmsilva
in reply to: JustinTCox


@JustinTCox wrote:

when I use -dgnimport it opens the .dgn in a new window, therefor stops the script and lisp


It was just a thought, I don't have AutoCAD with me to test it ...

 

Henrique

EESignature

Message 7 of 7
hmsilva
in reply to: JustinTCox


@JustinTCox wrote:

when I use -dgnimport it opens the .dgn in a new window, therefor stops the script and lisp


With a script and SDI=1, should work ok...

 

EDIT: As a 'demo', change the dgn path and name to the correct one for testing.

 

(defun c:dgnin (/ CurrDwg Dgn Old_dia OpFil Sav ScrFil)
  (if (= (getvar 'SDI) 1)
    (progn
      (setq Dgn	    "C:\\Your\\Path\\TEST01.DGN"
	    ScrFil  "C:\\temp\\Temp.scr"
	    CurrDwg (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
	    old_dia (getvar 'FILEDIA)
	    OpFil   (open ScrFil "W")
      )
      (if (findfile "C:\\temp\\TempDwg.dwg")
	(setq sav (strcat "_.save" "\r" "C:\\temp\\TempDwg.dwg" "\r" "Y" "\r"))
	(setq sav (strcat "_.save" "\r" "C:\\temp\\TempDwg.dwg" "\r"))
      )
      (setvar 'FILEDIA 0)
      (command "_.qsave")
      (write-line (strcat "_.qnew" "\r" "." "\r") OpFil)
      (write-line (strcat "-dgnimport" "\r" Dgn "\r" "\r" "\r" "\r") OpFil)
      (write-line sav OpFil)
      (write-line (strcat "_.open" "\r" CurrDwg "\r") OpFil)
      (write-line (strcat "_.insert" "\r" "C:\\temp\\TempDwg.dwg" "\r" "0,0,0" "\r" "1" "\r" "1" "\r" "0" "\r") OpFil)
      (write-line (strcat "FILEDIA" "\r" (itoa old_dia) "\r") OpFil)
      (close OpFil)
      (command "_.script" ScrFil)
    )
    (prompt "\n Progrm only runs with SDI = 1 !!!")
  )
  (princ)
)

 

HTH

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost