oldluke Posted February 11, 2021 Share Posted February 11, 2021 Hey all, I'm Lukas and I am new to scripting with Python and working in Vectorworks. Basically I want to import a folder with 3dm files from Rhino into Vectorworks with each file on a new class. My Script (copied from the internet) now looks like this but isn't finished yet (obviously). import os major, minor, maintenance, platform = vs.GetVersion() isMac = False if platform == 1: isMac = True err, dirPath = vs.GetFolder( 'Select a Folder' ) if err == 0: # no-error hsfDirPath = dirPath if isMac: ok, hsfDirPath = vs.ConvertPosix2HSFPath( dirPath ) fileIndex = 1 while True: # loop the files fileName = vs.GetFilesInFolder( hsfDirPath, fileIndex ) fileIndex += 1 if fileName == '': # no more files break name, ext = os.path.splitext( fileName ) if ext.lower() == '.3dm': filePath = os.path.join( dirPath, fileName ) vs.BeginSym( name ) hFile = vs.ImportDXFDWG() vs.EndSym() vs.AlrtDialog( 'Done!' ) I was unable to find a dedicated function to import 3dm files. Is there a function like vs.ImportDXFDWG() but for 3dm files? How do I implement in the loop the class creation with each class named like the file. Thanks in advance to all. Quote Link to comment
MullinRJ Posted February 12, 2021 Share Posted February 12, 2021 @oldluke Yes, check out the Script Function Reference, either in your application folder in the HELP directory, or online at the Developer Wiki at https://developer.vectorworks.net/index.php/Main_Page and use the search function. I find the one in the HELP folder much quicker to use, but often there are more comments in the online version. Use both. FUNCTION Import3DSFile ( fileName :DYNARRAY[] of CHAR; atOrigCoords :BOOLEAN; positionX, positionY :REAL ) :BOOLEAN ; def vs.Import3DSFile(fileName, atOrigCoords, positionX, positionY): return BOOLEAN HTH, Raymond Quote Link to comment
MullinRJ Posted February 12, 2021 Share Posted February 12, 2021 (edited) Sorry, I misread your post. I see you want 3DM files, not 3DS files. I don't believe there is a canned function that supports 3DM files. You might try: vs.DoMenuTextByName('Import Rhino 3DM (3D only)', 0) This call will present an Open File dialog, same as the menu item. Not sure if this helps. Raymond Edited February 12, 2021 by MullinRJ Quote Link to comment
oldluke Posted February 15, 2021 Author Share Posted February 15, 2021 Hey Raymond, Thx for your reply. That sort of works, but when I have a lot of 3DM files (maybe about 100) I don't want to select every one by hand in the open file dialog. Is there a way to automate this, so I have to just choose the folder (like vs.GetFolder) and every file is imported to a new class? Kind Regards Lukas Quote Link to comment
Pat Stanford Posted February 16, 2021 Share Posted February 16, 2021 Have you tried just dragging the files into a drawing window? It might avoid the having to specify the file in the dialog box. Quote Link to comment
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.