Importing .dxf / .obj / .fbx with grasshopper

Hi all,

Like the title mentions, I’m looking for a way to import .dxf / .obj / .fbx with grasshopper.
I’ve seen some mentioned and tried a few solutions but unfortunately without any succes, hoping for some help with this post.

I’ve tried out this solution.

Script down below:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino


        
def importToGrasshopper(fileType, fileName, filePath):

    # check the input data
    if fileType:
        if fileType.startswith("."):
            pass
        else:
            fileType = "." + fileType
            
        supportedFileTypes = [".3dm", ".3ds", ".sat", ".ai", ".dwg", ".dxf", ".dae", ".cd", ".x", ".emf", ".gf", ".pm", ".kmz", ".gts", ".igs", ".iges", ".udo", ".fbx", ".obj", ".csv", ".x_t", ".pdf", ".ply", ".txt", ".pov", ".raw", ".rib", ".skp", ".step", ".stl", ".tsm", ".tss", ".vda", ".wrl", ".vmrl", ".gdf", ".wmf", ".x3dv", ".xaml", ".xgl", ".zpr"]
        if fileType in supportedFileTypes:
            pass
        else:
            print "File type %s is not supported" % fileType
            return
    else:
        print "Please input fileType"
        return
    
    if fileName:
        pass
    else:
        print "Please input fileName"
        return
    
    if filePath:
        if filePath.endswith("\\"):
            pass
        else:
            filePath = filePath + "\\"
    else:
        return
        print "Please input filePath"


    # geometryTypes functions


    fileNameAndType = fileName + fileType
    finalPath = filePath + fileNameAndType
    
    commandString = "_-Import " + finalPath + " _Enter _Enter _Enter" 
        
    done = rs.Command(commandString)
    if done:
        print "%s file successfully imported from: %s" % (fileNameAndType, filePath)



if Import:
    importToGrasshopper(fileType, fileName, filePath)

The script has some problems with the white spaces in the file path and can not import anything because of it.

Thank you :slight_smile:

You can use the “Import 3dm” component in Rhino 7 to read all of the file formats that Rhino supports.

oh wow, I did not realize that. Thanks for the tip!

Any idea why it’s still called “import 3dm” as it supports multiple formats?

The component already existed as “Import 3dm” in Rhino 6. I added the ability to support non-3dm paths without creating a new component type in Rhino 7.

1 Like

I see. Thanks.

Attached my GH file. Perhaps I’m doing something wrong. I have a system which checks for new .dxf files and checks if an export is already made to .fbx of the same .dxf. Can I use the import 3dm component in this way? I think I need a boolean toggle to determine which ones can be exported and which ones don’t have to. Struggling with the import geo method a bit.

ImportGeo.gh (19.4 KB)

Strange enough .dxf are not supported?

It should be. I drew a few curves in Rhino and exported them as a dxf. They came in fine with the import 3dm component

I’ve changed the input from .dxf to .fbx and it all works now. Perhaps that is a better flow for me anyway :slight_smile:
Thanks for the help!

Hi Remy -

I see that here and put it on the list as RH-65519.
Thanks,
-wim

The DXF that you posted earlier was entirely composed of blocks. Grasshopper doesn’t support blocks. What do you think the component should do in cases like this?

Hi, @stevebaer any thoughts about this problem? @wim

Replied in original thread

1 Like