Write 3dm file

Hi Steve
The below Python script don’t save a file 3dm. Where I went wrong?

import Rhino
print file_3dm
print file_3dm
print p
print a

Ciao Vittorio

Hmm, how do you actually REMOVE a post…?

Hi Mitch
I did not understand your question.
Ciao Vittorio

As far as I can tell right now, you ask a McNeel person to do it.


The path string has unescaped backslashes in it. In python (like many other languages), a backslash in a string means that you are defining a special character. For example

# the \n in the following string represents a newline character
s = "Two\nLines"

The way to create single backslashes in a string is to type \ \

So… to fix your script, change the line to

a = file_3dm.Write("C:\\BENACCHIO\\as.3dm",5)

Hi Steve
Perfect, all is OK. Grazie mille
Ciao Vittorio

I Steve
I can not find the method to add more items to the file:

#-*- encoding: UTF-8 -*-
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

file_3dm=Rhino.FileIO.File3dm() # qui creo l'oggetto file da salvare

print file_3dm
p1=Rhino.Geometry.Point3d(0,0,0) #creo i punti per disegnare la linea
# there is a method to add more objects?
p=file_3dm.Objects.AddLine(line) #creo la linea i metodi sono quelli di
                            # Rhino.DocObjects.Tables.(Add,Addarc,AddLine ecc.))
                            #oppure in scriptcontext.doc.objects.(Add,AddArc,AddLine ecc.)


Ciao Vittorio

There are a bunch of different “Add” functions for the object table

Is there one in particular that you are having problems with?