Exemplo n.º 1
0
import rhino3dm
import random

model = rhino3dm.File3dm()

for i in xrange(10):
    pt = rhino3dm.Point3d(random.randint(0, 10), random.randint(0, 10), 0)
    circle = rhino3dm.Circle(pt, float(random.randint(0, 5)))
    model.Objects.AddCircle(circle)

model.Write("add_random_circles.3dm", 5)
Exemplo n.º 2
0
    def rhino_pre_deal(self,content,file_name='test',cover=True):
        tag_list=[  "aerialway",
                    "aeroway",
                    "amenity",
                    "barrier",
                    "boundary",
                    "building",
                    "craft",
                    "emergency",
                    "geological",
                    "highway",
                    "historic",
                    "landuse",
                    "leisure",
                    "man_made",
                    "military",
                    "natural",
                    "office",
                    "place",
                    "power",
                    "public_transport",
                    "railway",
                    "route",
                    "shop",
                    "sport",
                    "tourism",
                    "waterway"]
        layer_list=[]

        self.model=rhino3dm.File3dm()
        objects=self.model.Objects
        layers=self.model.Layers



        for way in self.info_dict['way_info']:
            temp=self.info_dict['way_info'][way]
            for i in temp['info']:
                if i in tag_list:
                    layer_name='{}${}'.format(i,temp['info'][i])
                    if layer_name not in layer_list:
                        layer_list.append(layer_name)
                        tem_layer=rhino3dm.Layer()
                        tem_layer.Name = layer_name
                        layers.Add(tem_layer)
                    break
  
            line = rhino3dm.Polyline()
            for node in temp['nodes']:
                line.Add(node[0],node[1],0)
            
            object_id = objects.AddPolyline(line)
            '''
            for xxx in objects:
                j=j+1
                if xxx.Attributes.Id == object_id:
                    print(j)
            '''
            print(objects[len(objects)-1].Attributes.Id)
            #print(layers.FindName(layer_name,None).Index)
            objects[len(objects)-1].Attributes.LayerIndex = layers.FindName(layer_name,None).Index
        return(True)