<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Importing/Converting STEP files to DWGs using LISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544613#M18167</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15010404"&gt;@jason_aPCJML&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P class=""&gt;...I have a few thousand ST(E)Ps that I need to turn into DWGs...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can always purchase a fix designed for the task&amp;nbsp;&lt;A href="https://cadsofttools.com/products/abviewer/tutorials/how-to-convert-3d-model-to-dwg/" target="_blank"&gt;https://cadsofttools.com/products/abviewer/tutorials/how-to-convert-3d-model-to-dwg/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 22:05:09 GMT</pubDate>
    <dc:creator>pendean</dc:creator>
    <dc:date>2024-02-06T22:05:09Z</dc:date>
    <item>
      <title>Importing/Converting STEP files to DWGs using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544560#M18166</link>
      <description>&lt;P class=""&gt;I have a few thousand ST(E)Ps that I need to turn into DWGs. I tried writing a script with LISP but I can't seem to get it to actually import anything. I've included the script I am trying to use and a comment on the line that is failing. I've only done very basic programming in LISP so I'm not the best at debugging it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;Is this the best solution for programmatically converting STPs to DWGs? (preferably through ACAD, open to other local conversion tools as well) Any pointers, resources, or help is greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;I originally had the import line as "-Import" But that would result in this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;From my understanding the "-" means to call the function with params instead of popping up a dialog, but I don't think this issue is related to the Import command not working/me not understanding how to call it properly.&lt;BR /&gt;&lt;BR /&gt;Here is the script I am trying to run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun process-step-files (/ step-files output-dir)
  (setq step-files (vl-directory-files "C:/Steps/" "*.step" 1))
  (setq output-dir "C:/DWGs/") 

  (if (null step-files)
      (prompt "\nNo .stp files found in the specified directory.")
    (progn
      (foreach step-file step-files
        (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
        (setq model-space (vla-get-ModelSpace doc))
	(prompt "\nImporting...\n")
	(prompt (strcat "C:/Steps/" step-file))
        (command-s "IMPORT" (strcat "C:/Steps/" step-file)) ; FAILING ON THIS LINE/NOT MAKING IT PAST THIS LINE
	(prompt "\nStep 1")
        (setq imported-objects (vla-get-ImportedObjects doc))
	(prompt "\nStep 2")
        (setq imported-object (vla-item imported-objects 0))
	(prompt "\nMoving imported object into model-space...")
        (vla-move imported-object '(0 0 0) model-space)
	(prompt "\nSaving...")
        (command-s "-SAVEAS" (strcat output-dir (vl-filename-base step-file) ".dwg") "2018")
      )
      (princ "\nConversion process complete.")
    )
  )
)

(process-step-files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 21:39:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544560#M18166</guid>
      <dc:creator>jason_aPCJML</dc:creator>
      <dc:date>2024-02-06T21:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Importing/Converting STEP files to DWGs using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544613#M18167</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15010404"&gt;@jason_aPCJML&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P class=""&gt;...I have a few thousand ST(E)Ps that I need to turn into DWGs...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can always purchase a fix designed for the task&amp;nbsp;&lt;A href="https://cadsofttools.com/products/abviewer/tutorials/how-to-convert-3d-model-to-dwg/" target="_blank"&gt;https://cadsofttools.com/products/abviewer/tutorials/how-to-convert-3d-model-to-dwg/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 22:05:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544613#M18167</guid>
      <dc:creator>pendean</dc:creator>
      <dc:date>2024-02-06T22:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing/Converting STEP files to DWGs using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544620#M18168</link>
      <description>&lt;P&gt;I don't have any step files to try this on but perhaps you can attach a couple of samples?&lt;/P&gt;&lt;P&gt;What happens if you change this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command-s "IMPORT" (strcat "C:/Steps/" step-file))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command "_.-IMPORT" (strcat "C:/Steps/" step-file))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also this line fails:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq imported-objects (vla-get-ImportedObjects doc))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because there's no such function as&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;vla-get-ImportedObjects&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is there a reason for moving the imported objects when you should be already in Model space?&lt;/P&gt;&lt;P&gt;Now this line of code would save and switch your current drawing to that new drawing file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command-s "-SAVEAS" (strcat output-dir (vl-filename-base step-file) ".dwg") "2018")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps just use the Save command and give it a different name. Then you won't be in that newly saved file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command "_.-SAVE" (strcat output-dir (vl-filename-base step-file)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before the foreach loop finishes to start on the next step file you can erase everything imported like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command "_.Erase" "_All" "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 22:12:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544620#M18168</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-02-06T22:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing/Converting STEP files to DWGs using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544822#M18169</link>
      <description>&lt;P&gt;I would go back a step and use a script you can write the script using a lisp file to get step file names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second suggestion is if step file name has spaces can cause problems as the space is used as a "end of", so may need the step file to be "c:\\step\\this is my file name". You need the import to run without any user input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this. just write down all the steps when you do "import" manually to work correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;New
(setvar ctab 'model)
(command-s  "-import" "C:\\steps\\file 1" there may be more steps here)
(command-s "-SAVEAS" (strcat "C:\\mysteps out"  (vl-filename-base "C:\\steps\\file 1") ".dwg") "2018")
close
New
(setvar ctab 'model)
(command  "-import" "C:\\steps\\file 2" )
(command "-SAVEAS" (strcat "C:\\mysteps out" (vl-filename-base step-file) ".dwg") "2018")
close
New
(setvar ctab 'model)
(command-s  "-import" "C:\\steps\\file 3" .....)
(command-s "-SAVEAS" (strcat "C:\\mysteps out" (vl-filename-base step-file) ".dwg") "2018")
close&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 01:19:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-converting-step-files-to-dwgs-using-lisp/m-p/12544822#M18169</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-02-07T01:19:20Z</dc:date>
    </item>
  </channel>
</rss>

