mzlink Posted January 6, 2017 Share Posted January 6, 2017 Hello. I have tried to edit a script found in another topic to suit my needs but i can't get it to work the way i want to. layer2dwg (defun c:lsave(/ actDoc layCol docName dwgName actSel fCount) (vl-load-com) (defun BrowseFolder (/ ShlObj Folder FldObj OutVal) (vl-load-com) (setq ShlObj (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ) Folder(vlax-invoke-method ShlObj 'BrowseForFolder 0 "Select Folder to create files" 0) ) (vlax-release-object ShlObj) (if Folder (progn (setq FldObj (vlax-get-property Folder 'Self) OutVal (vlax-get-property FldObj 'Path) ) (vlax-release-object Folder) (vlax-release-object FldObj) OutVal ) ) ) (setq actDoc(vla-get-ActiveDocument (vlax-get-acad-object)) actSel(vla-get-ActiveSelectionSet actDoc) layCol(vla-get-Layers actDoc) docName(vla-get-Name actDoc) fCount 0 ); end setq (if (setq wntPath (BrowseFolder)) (progn (vlax-for lay layCol (setq layName(vla-get-Name lay) dwgName (strcat wntPath "\\" (vl-filename-base docName) " - " layName ".dwg") ); end setq (vla-clear actSel)(vla-erase actSel) (vla-Select actSel acSelectionSetAll nil nil (vlax-safearray-fill (vlax-make-safearray vlax-vbInteger '(0 . 0)) '( ) ; end vla-safearray-fill (vlax-safearray-fill (vlax-make-safearray vlax-vbvariant '(0 . 0)) (list layName) ) ; end vla-safearray-fill ) ; end vla-select (if(/= 0(vla-get-Count actSel)) (vla-WBlock actDoc dwgName actSel)); end if (setq fCount(1+ fCount)) ); end vlax-for ); end progn ); end if (princ (strcat "\*** " (itoa fCount) " files were created *** ")) (princ) ); end of c:lsave I have poked the "WBlock" line in different ways but i can't get FBXEXPORT to work in the script. Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted January 6, 2017 Share Posted January 6, 2017 There is no 'vla' method for exporting to FBX. You will have to work with the -FBXEXPORT command I think. Quote Link to comment Share on other sites More sharing options...
mzlink Posted January 7, 2017 Author Share Posted January 7, 2017 There is no 'vla' method for exporting to FBX. You will have to work with the -FBXEXPORT command I think. I'm just getting errors about "export" / "fbxexport" function not existing when trying to run it in a lsp script. Any ideas for fixing the script? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted January 7, 2017 Share Posted January 7, 2017 I cannot help you with a detailed answer as I use BricsCAD 16 instead of AutoCAD. But you will have to analyse how the -FBXEXPORT command works and then write code containing something like this: (command "_.-FBXEXPORT" ...) Your code sample would have to be completely rewritten. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 7, 2017 Share Posted January 7, 2017 Try the following: (defun c:lay2fbx ( / cmd def dir sel spc ) (setq cmd (getvar 'cmdecho) dir (getvar 'dwgprefix) spc (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")) ) (setvar 'cmdecho 0) (while (setq def (tblnext "layer" (null def))) (if (and (zerop (logand (cdr (assoc 70 def)) 21)) (setq sel (ssget "_X" (list (cons 8 (cdr (assoc 2 def))) spc))) ) (vl-cmdf "_.-fbxexport" "_S" sel "" "_A" "_E" (LM:uniquefilename (strcat dir (cdr (assoc 2 def)) ".fbx"))) ) ) (setvar 'cmdecho cmd) (princ) ) ;; Unique Filename - Lee Mac ;; Returns a filename suffixed with the smallest integer required for uniqueness (defun LM:uniquefilename ( fnm ) (if (findfile fnm) (apply '(lambda ( pth bse ext / tmp ) (setq tmp 1) (while (findfile (setq fnm (strcat pth bse "(" (itoa (setq tmp (1+ tmp))) ")" ext)))) ) (fnsplitl fnm) ) ) fnm ) (princ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted January 7, 2017 Share Posted January 7, 2017 Lee, if my eyes don't fool me, you forgot to add (fnsplitl fnm) sub function... I know it's dummy, but anyway, it's just me and my remark... Happy Christmas holidays and new year... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 7, 2017 Share Posted January 7, 2017 Lee, if my eyes don't fool me, you forgot to add (fnsplitl fnm) sub function... I know it's dummy, but anyway, it's just me and my remark... Happy Christmas holidays and new year... No - fnsplitl is a standard AutoLISP function Happy New Year to you too. Quote Link to comment Share on other sites More sharing options...
mzlink Posted January 8, 2017 Author Share Posted January 8, 2017 Try the following: [#CODE] Works perfectly. Tyvm :thumbsup: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 8, 2017 Share Posted January 8, 2017 Works perfectly. Tyvm :thumbsup: Excellent - you're welcome! Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 8, 2017 Share Posted January 8, 2017 That LM:uniquefilename is cleverly written, I like it! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 8, 2017 Share Posted January 8, 2017 That LM:uniquefilename is cleverly written, I like it! Thank you Grrr! Quote Link to comment Share on other sites More sharing options...
Jnanashakthi Posted September 14, 2021 Share Posted September 14, 2021 (edited) Very nice... I am searching for this.. I wrote a simple autolisp shortcut n use it by freezing each layer n giving one file name every time.. You saved my time... Thanks you Edited September 14, 2021 by Jnanashakthi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.