Jump to content
oldluke

Import 3dm to new classes

Recommended Posts

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.

 

 

 

Share this post


Link to post

@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

Share this post


Link to post

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 by MullinRJ

Share this post


Link to post

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

Share this post


Link to post

Have you tried just dragging the files into a drawing window? It might avoid the having to specify the file in the dialog box.

Share this post


Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...