Author Topic: 2015 - fibres - command-s vs. command  (Read 3471 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
2015 - fibres - command-s vs. command
« on: May 07, 2014, 11:12:36 AM »
In 2015, with the elimination of "fibres" I have problems using "command" in this scenario:

...vla-Open dwg file...
(vl-cmdf "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")

Loading (and run inside itself) LispFile with sendcommand I can execute all I need (plot, export, etc.) and when I close the document the control go back to the starting document. I think it is a better method than scripts especially for errors check.

I thought I should abandon this method because it is very slow in 64-bit systems (due to the VBA 6/64, see my previous post), but in AutoCAD 2014 (with VBA 7) is back to being useful and very fast.

But in 2015

1) If i use:
(vl-cmdf "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")
AutoCAD hang and loop this request: INTERNAL ERROR: VL namespace mismatch type Y to reset

2) If i use:
(command "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")
I get this error (Function cancelled)
Code: [Select]
[0.51] (VL-BT)
[1.47] (ERRDUMP "Function cancelled")
[2.42] (_call-err-hook #<SUBR @0000001c65b86c50 ERRDUMP> "Function cancelled")
[3.36] (sys-error "Function cancelled"):ERROR-BREAK.31 "Function cancelled"
[4.28] (sys-rtcan-hook)
[5.24] (ads-cmd "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")
[6.19] (C:ALE_SCMD_BATCHMULTIPLE)
[7.15] (#<SUBR @0000001c65b86ea8 -rts_top->)
[8.12] (#<SUBR @0000001c65678700 veval-str-body> "(C:ALE_SCMD_BATCHMULTIPLE)" T #<FILE internal>)
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY):ARQ-SUBR-CALLBACK.3 (nil 0)

3) If i use:
(command-s "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")
I get this error (Unknown command)
Code: [Select]
[0.48] (VL-BT)
[1.44] (ERRDUMP "Error (command-s) unknown.")
[2.39] (_call-err-hook #<SUBR @0000001c656bcae8 ERRDUMP> "Error (command-s) unknown.")
[3.33] (sys-error "Error (command-s) unknown.") :ERROR-BREAK.28 "Error (command-s) unknown."
[4.25] (COMMAND-S "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"LispFile\"\")\n\"")
[5.19] (C:ALE_SCMD_BATCHMULTIPLE)
[6.15] (#<SUBR @0000001c656bcd40 -rts_top->)
[7.12] (#<SUBR @0000001c65678700 veval-str-body> "(C:ALE_SCMD_BATCHMULTIPLE)" T #<FILE internal>) :CALLBACK-ENTRY.6 (:CALLBACK-ENTRY):ARQ-SUBR-CALLBACK.3 (nil 0)

Suggestions?

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: 2015 - fibres - command-s vs. command
« Reply #1 on: May 07, 2014, 05:58:16 PM »
Dumb Question Maybe - but do you have VBA Installed?
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Kean

  • Newt
  • Posts: 48
Re: 2015 - fibres - command-s vs. command
« Reply #2 on: May 08, 2014, 03:50:39 AM »
If I copy & paste into the command-line in my AutoCAD 2015 installation, I simply get an error saying that LispFile could not be found/loaded (which means it basically works, unless I need to do a (vla-Open) to reproduce the problem). I do have VBA installed.

I don't recommend calling a command from LISP to run a VBA statement that sends a command to load a LISP file, though. ;-) (Apart from anything else placing a requirement on VBA being installed makes the code more fragile.)

I assume the goal is to run your LISP in certain drawings that are opened programmatically... Another option would be to use acaddoc.lsp or the Autoloader to load a LISP file in each drawing (even those that are loaded manually by the user) and check some state (perhaps a sysvar) to see whether there's a particular routine that needs to be executed.

It would be quite different if you were using .NET, so I'm having to use an under-used part of my brain to think this through. Which means there may well be better approaches.

Kean

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: 2015 - fibres - command-s vs. command
« Reply #3 on: May 08, 2014, 04:50:22 AM »
@PKENEWELL: Yes I have.

If I copy & paste into the command-line in my AutoCAD 2015 installation, I simply get an error saying that LispFile could not be found/loaded (which means it basically works, unless I need to do a (vla-Open) to reproduce the problem). I do have VBA installed.

I don't recommend calling a command from LISP to run a VBA statement that sends a command to load a LISP file, though. ;) (Apart from anything else placing a requirement on VBA being installed makes the code more fragile.)

I assume the goal is to run your LISP in certain drawings that are opened programmatically... Another option would be to use acaddoc.lsp or the Autoloader to load a LISP file in each drawing (even those that are loaded manually by the user) and check some state (perhaps a sysvar) to see whether there's a particular routine that needs to be executed.

It would be quite different if you were using .NET, so I'm having to use an under-used part of my brain to think this through. Which means there may well be better approaches.

Kean

Try (see attached):
Code: [Select]
(defun C:TestSD (/ @AcDwg)
  (vl-load-com)
  (and (= (getvar "CLISTATE") 1) (command "_.COMMANDLINEHIDE"))
  (or *AcadApp* (setq *AcadApp* (vlax-get-acad-object)))
  (or *AcAcDwg* (setq *AcAcDwg* (vla-get-ActiveDocument *AcadApp*)))
  (or *AcDrwgs* (setq *AcDrwgs* (vla-get-documents *AcadApp*)))
  (foreach ForElm '("c:\\Temp\\Test1.dwg" "c:\\Temp\\Test2.dwg")
    (if (vl-catch-all-error-p (setq @AcDwg (vl-catch-all-apply 'vla-Open (list *AcDrwgs* ForElm :vlax-false))))
      (progn (alert (vl-catch-all-error-message @AcDwg)) (setq @AcDwg nil))
      (vl-cmdf "_.VBASTMT" "documents.item(documents.count-1).sendcommand \"(load \"\"VLSc\"\")\n\"")
    )
  )
  (and (= (getvar "CLISTATE") 0) (command "_.COMMANDLINE"))
  (princ)
)

I am using this method from about version 2000, less problem of scripts, acaddoc.lsp or Autoloader
in case of shutdown of the processing (IMHO).
About .NET... it is not for me (too old...  :'( )