Jump to content

ATTSYNC on lisp from scr with accorconsole.exe


Recommended Posts

Posted

Good morning everyone,

I have an issue with a *.scr which run with AccoreConsole.exe. This *.scr run a lisp to ATTSYNC a specific block and zoom. Then, *.scr "_QSAVE" the file. I'm using Accoreconsole.exe to execute the script

However, it's like the lisp 's not running... Could you help me ?

 

the *.lisp (no space at the end - it's french autocad)

(defun c:lisp_attsync nil
	(command "attsync" "_name" "CO_XX_XX_EL_BLOCK")
	(command "zoom" "ETendu")
)

 

the *.scr

FILEDIA
0
(LOAD "C:\\Temp\\lisp_attsync.lsp")
(lisp_attsync)
_QSAVE
FILEDIA
1

 

and the commande to accoreconsole.exe

C:\Temp>"C:\Program Files\Autodesk\AutoCAD 2015\accoreconsole.exe" /i "C:\Temp\CH_SP_04_BT_CR_304_F016.dwg" /s attsyn.scr /l fr-FR

 

however it's like there is nothing... and of course, only "_Qsave" command works..

Commande:
C:\Temp>"C:\Program Files\Autodesk\AutoCAD 2015\accoreconsole.exe" /i "C:\Temp\CH_SP_04_BT_CR_304_F016.dwg" /s attsyn.scr /l fr-FR
AutoCAD Core Engine Console - Copyright Autodesk, Inc 2009-2013.






Remplacement de [romans8] par [simplex.shx].
Régénération du modèle.
Appuyez sur  ENTREE pour continuer:

Commande:
Commande:

Commande:
Commande: FILEDIA

Entrez une nouvelle valeur pour FILEDIA <0>: 0

Commande: (LOAD "C:\\Temp\\lisp_attsync.lsp")


Commande: (lisp_attsync)


Commande: _QSAVE

Commande: FILEDIA

Entrez une nouvelle valeur pour FILEDIA <0>: 1

Commande: _quit

Commande:
C:\Temp>

 

If I change the commande to run the lisp with an undefined command ("nothing_real for example), there isn't warning :

Entrez une nouvelle valeur pour FILEDIA <0>: 0

Commande: (LOAD "C:\\Temp\\lisp_attsync.lsp")


Commande: (nothing_real)


Commande: _QSAVE

Commande: FILEDIA

Entrez une nouvelle valeur pour FILEDIA <0>: 1

Commande: _quit

 

So what's wrong ? Thank for your help

Posted (edited)

Update your .scr file.

 

(defun c:lisp_attsync nil ;nil is fine but i always use 

Try to use all the commands in the lisp.
(defun c:lisp_attsync ()
  (command "attsync" "_name" "CO_XX_XX_EL_BLOCK")
  (command "zoom" "ETendu")
  (command "_.Qsave")           ;I might have a variable set but this stays in the command prompt even with filedia =1 set
  (command "_.Close")           ;autosaves if alreay a file. asks for a file path if not saved already.
)

Your issue When Calling lisps have what the defun is named.
(lisp_attsync) doesn't work
(c:lisp_attsync) works	
Edited by mhupp
Posted

Thanks for your answer, but there still an issue...

 

I saved the folder c:\Temp as safe folder for autocad, and now the lisp is running. => Good !

But... Accoreconsole doesn't know "ATTSYNC"...

Commande: (c:lisp_attsync)
ATTSYNC Commande inconnue "ATTSYNC".  Appuyez sur F1 pour obtenir de l'aide.

Commande: name Commande inconnue "NAME".  Appuyez sur F1 pour obtenir de l'aide.

Commande: CO_XX_XX_EL_

 

 

Any Idea ?

thanks a lot.

 

 

Posted (edited)

Try "_.attsync" to force the English command.  either the _ or the . does that.

or it might be an Express tool command idk.

 

--EDIT--

Source

Adding the "dot" before a command name ensures that the generic AutoCAD command will be used instead of one that might be
substituted (or missing) by virtue of the command having been undefined. You might also see/use (command "_.LIST" ...) wherein the
underscore ensures that the command will be recognized by its English language despite the actual language being used.

--EDIT 2--

Read These

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attsync-in-accoreconsole/td-p/8440291

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/can-t-run-my-selfmade-lsp-in-accoreconsole/td-p/7437946

 

Edited by mhupp
Posted

thanks, but no...

(defun c:lisp_attsync ()
  (command "_.attsync" "_NAME" "CO_XX_XX_EL_BLOCK")
  (command "_.zoom" "ETendu")
  (command "_.Qsave")
  (command "_.Close") 
)

(defun c:lisp_attsync ()
  (command "_.attsync" "_NAME" "CO_XX_XX_EL_BLOCK")
  (command "_.zoom" "ETendu")
  (command "_.Qsave")
  (command "_.Close") 
)

 

I'm going to look Express tool...

 

 

Posted (edited)

You could always just run the script inside AutoCAD with the script command.

This is what I use to build script files  from a single folder. had one that would read off a txt file outputted from cmd of all the file paths but cant find it.

 

but first see if attsync is a command in your AutoCAD first.

 

;;----------------------------------------------------------------------------;;
;; Make script file for ATTSYN drawings in a folder.
(defun C:FOO (/ Path  F1 FileName)
  (setq Path (vl-filename-directory (getfiled "Choose a Folder to Process" (getvar 'DWGPREFIX) "*" 16)) ;click on a file to set folder location.
        fname (vl-directory-files Path "*.dwg" 1) ;list all file types of this type.
        fname (vl-remove (getvar 'DWGNAME) fname)
        fname (vl-sort fname '<)
        F (open (strcat (getenv "userprofile") "\\Documents\\Script.scr") "w")  ;saves script file to your mydocuments folder.
  )
  (if (= nil fname)
    (prompt "\nNo Drawings Found in Folder")
    (progn
      (foreach FileName fname
        (princ (strcat "_.Open \"" Path "\\" FileName "\"\n") F)  ;change " to \"
        (princ "(LOAD \"C:\\Temp\\lisp_attsync.lsp\")\n" F)
        (princ "(c:lisp_attsync)\n" F)
      )
      (princ "(prompt \"ATTSYN COMPLETE\")\n" F)
    )
  )
  (close F)
  ;(vl-cmdf "_.Script" (strcat (getenv "userprofile") "\\Documents\\Script.scr")) ;uncomment to run automatically
  (princ)
)

 

Edited by mhupp
typo
Posted

Thanks a lot, Amazing !

 I just change the lisp like this :

(defun c:lisp_attsync ()
  (command "_.attsync" "_NAME" "CO_XX_XX_EL_Cartouche SPSE ELEC A3")
  (command "_.zoom" "ETendu")
  (command "_.Qsave")
  ;(command "_.Close") <=comment this one
)

 and add the command "_.close" to your script

;;----------------------------------------------------------------------------;;
;; Make script file for ATTSYN drawings in a folder.
(defun C:FOO (/ Path  F1 FileName)
  (setq Path (vl-filename-directory (getfiled "Choose a Folder to Process" (getvar 'DWGPREFIX) "*" 16)) ;click on a file to set folder location.
        fname (vl-directory-files Path "*.dwg" 1) ;list all file types of this type.
        fname (vl-remove (getvar 'DWGNAME) fname)
        fname (vl-sort fname '<)
        F (open (strcat (getenv "userprofile") "\\Documents\\Script.scr") "w")  ;saves script file to your mydocuments folder.
  )
  (if (= nil fname)
    (prompt "\nNo Drawings Found in Folder")
    (progn
      (foreach FileName fname
        (princ (strcat "_.Open \"" Path "\\" FileName "\"\n") F)  ;change " to \"
        (princ "(LOAD \"C:\\Temp\\lisp_attsync.lsp\")\n" F)
        (princ "(c:lisp_attsync)\n" F)
		(princ "_.Close\n" F)
      )
      (princ "(prompt \"ATTSYN COMPLETE\")\n" F)
    )
  )
  (close F)
  ;(vl-cmdf "_.Script" (strcat (getenv "userprofile") "\\Documents\\Script.scr")) ;uncomment to run automatically
  (princ)
)

 

I aslo add double \ to the location of lisp_attsync.lsp because Script.scr has only one. (I did this with NotePade+).

_.Open "C:\Temp\CH_SP_04_EL_EL_EL_SP_04_0001_F14.dwg"
(LOAD "C:\\Temp\\lisp_attsync.lsp")
(c:lisp_attsync)
_.Close
_.Open "C:\Temp\CH_SP_04_EL_EL_EL_SP_04_0001_F16.dwg"
(LOAD "C:\\Temp\\lisp_attsync.lsp")
(c:lisp_attsync)
_.Close
(prompt "ATTSYN COMPLETE")

 

 

Thanks a lot again, this script will run on 16590 electric dwg....

 

Posted
1 hour ago, Jarod1990 said:

Thanks a lot again, this script will run on 16590 electric dwg....

 

it will take along time to run though all those. might want to split it up into 8th's or something with notepad++.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...