Author Topic: Export Igs  (Read 235 times)

0 Members and 1 Guest are viewing this topic.

WOWENS

  • Newt
  • Posts: 64
Export Igs
« on: April 29, 2024, 11:29:39 AM »
The following code works in AutoCAD 2024 and 2025 but fails to export all items in AutoCAD 2023 or 2022
it won't export anything after the first item is done. any ideas why?

Code - Auto/Visual Lisp: [Select]
  1. (Defun C:IGSOUT(/ i DwgNamePerfix IGSPath BlkName Layer DwgName sset ent1 BlockName IgsName MyList)
  2.         (setq OldPlot (getvar "Backgroundplot"))
  3.  
  4.         (setvar "Backgroundplot" 0)
  5.  
  6.         (prompt "\nSearching for items to export...")
  7.  
  8.         (setq DwgNamePerfix (getvar "dwgprefix"))
  9.         (setq IGSPath (strcat DwgNamePerfix "ISG Files"))
  10.  
  11.         (setq BlkName "RFI-*.3D")
  12.         (setq Layer "RFI")
  13.         (setq MyList (list ""))
  14.  
  15.         (setq sset (ssget "_X" (list (cons 0  "INSERT") (cons 2  BlkName) (cons 8 Layer))))
  16.  
  17.         (if (/= nil sset)
  18.                 (progn
  19.                         (prompt "\nPreparing to export Items...")
  20.  
  21.                         (if (null (vl-file-directory-p IGSPath))
  22.                                 (vl-mkdir IGSPath)
  23.                         )
  24.  
  25.                         (repeat (setq i (sslength sset))
  26.                                 (prompt "\nWorking....")
  27.  
  28.                                 (setq ent1 (ssname sset (setq i (1- i))))
  29.  
  30.                                 (setq BlockName (cdr (assoc 2 (entget ent1))))
  31.                                 (setq BlockName (vl-string-subst "" "RFI-" BlockName))
  32.                                 (setq BlockName (vl-string-subst "" ".3D" BlockName))
  33.  
  34.                                 (if (not (Member BlockName MyList))
  35.                                         (progn
  36.                                                 (setq MyList (CONS BlockName  MyList))
  37.                                                 (setq IgsName (strcat IGSPath "\\" BlockName ".igs"))
  38.  
  39.                                                 (command-s "._export" IgsName ent1 "")
  40.  
  41.                                                 (while (> (getvar 'CmdActive) 0) (command pause))
  42.                                         )
  43.                                 )
  44.  
  45.                         )
  46.                         (prompt "\nDone..")
  47.                 )
  48.                 (prompt "\nNothing Found to Export")
  49.         )
  50.  
  51.         (setvar "Backgroundplot" OldPlot)      
  52. )


EDIT (John): Added code tags.
« Last Edit: April 29, 2024, 12:17:59 PM by JohnK »

WOWENS

  • Newt
  • Posts: 64
Re: Export Igs
« Reply #1 on: April 29, 2024, 11:58:05 AM »
after testing my code more I found if there are too many blocks to export it won't work either even in AutoCAD 2024,
no problem with a few blocks but not a lot of blocks.
it has a problem waiting on (command-s "._export" IgsName ent1 "") to finish before doing the next export.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Export Igs
« Reply #2 on: April 29, 2024, 06:00:15 PM »
Assuming that the EXPORT command operates asynchronously, perhaps try adding a delay between each call to EXPORT using the DELAY command.

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Export Igs
« Reply #3 on: April 30, 2024, 10:55:34 AM »
Another possible problem is that (command-s...) needs a set of tokens representing the full command to run properly and cannot be split like you are doing. Also PAUSE may not be used in a (command-s) expression.

From AutoCAD 2024 Help:
Quote
  • Token streams fed in a single command-s expression must represent a full command and its input. Any commands in progress when command tokens are all processed will be cancelled.The following is not valid with the command-s function:
Code - Auto/Visual Lisp: [Select]
  1. (command-s "._line")
  2. (command-s "2,2" "12.25,9" "")
  • All command tokens will be evaluated before they are handed over to AutoCAD for execution. In contrast, the command function actually performs each command token evaluation and then feeds the result to AutoCAD, which processes it before the next command token is processed.
  • No "Pause" command tokens may be used. Expressions that interact with the drawing area or Command Window may be used, but will all be processed before AutoCAD receives and processes any of them. The following is not valid with the command-s function:
Code - Auto/Visual Lisp: [Select]
  1. (command-s "._line" "0,0" PAUSE "")

Consider changing to the standard (command) function.
"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