Exemple #1
0
def dxf_code(file_name, table_point, table_line, table_chain, table_shaft,
             table_slider, table_rod):
    mechanism = dxf.drawing(file_name)
    for i in range(len(table_point)):
        pt = dxf.point((table_point[i][3], table_point[i][4]))
        mechanism.add(pt)
    for i in range(len(table_line)):
        ln = dxf.line((table_point[table_line[i][0]][3],
                       table_point[table_line[i][0]][4]),
                      (table_point[table_line[i][1]][3],
                       table_point[table_line[i][1]][4]))
        mechanism.add(ln)
    for i in range(len(table_chain)):
        ln1 = dxf.line((table_point[table_chain[i][0]][3],
                        table_point[table_chain[i][0]][4]),
                       (table_point[table_chain[i][1]][3],
                        table_point[table_chain[i][1]][4]))
        ln2 = dxf.line((table_point[table_chain[i][1]][3],
                        table_point[table_chain[i][1]][4]),
                       (table_point[table_chain[i][2]][3],
                        table_point[table_chain[i][2]][4]))
        ln3 = dxf.line((table_point[table_chain[i][0]][3],
                        table_point[table_chain[i][0]][4]),
                       (table_point[table_chain[i][2]][3],
                        table_point[table_chain[i][2]][4]))
        mechanism.add(ln1)
        mechanism.add(ln2)
        mechanism.add(ln3)
    mechanism.save()
Exemple #2
0
def dxfSketch(VPointList, VLinkList, fileName):
    edges = v_to_slvs(VPointList, VLinkList)
    mechanism = dxf.drawing(fileName)
    for vpoint in VPointList:
        mechanism.add(dxf.point((vpoint.cx, vpoint.cy)))
    for p1, p2 in edges:
        vp1 = VPointList[p1]
        vp2 = VPointList[p2]
        mechanism.add(dxf.line((vp1.cx, vp1.cy), (vp2.cx, vp2.cy)))
    mechanism.save()
Exemple #3
0
	def converttodxf(self, nazwapliku = None, points = True, d3d = True):
		#konwertuje uzywajac modulu dxfwrite
		#points - czy wstawiac punkty wybierane podczas montazu
		if nazwapliku == None:
			nazwapliku = os.path.basename(self._nazwa_pliku)[:-3]+"dxf"
		from dxfwrite import DXFEngine as dxf
		drawing = dxf.drawing(nazwapliku)
		for OBJ in self._objects:
			#print "hehe"
			if OBJ==None:
				continue
			if OBJ.type()=='POINT':
				p=OBJ.P()
				if d3d:
					drawing.add(dxf.point((p[0],p[1],p[2])))
				else:
					drawing.add(dxf.point((p[0],p[1])))
			elif OBJ.type()=='LINE':
				p1=OBJ.P1(); p2=OBJ.P2()
				drawing.add(dxf.line((p1[0], p1[1]), (p2[0], p2[1])))
				#ent = adoc.CreateLine2(p1[0]/1000., p1[1]/1000., p1[2]/1000., p2[0]/1000., p2[1]/1000., p2[2]/1000.)
			elif OBJ.type()=='CIRCLE':
				p1=OBJ.O()
				drawing.add(dxf.circle(OBJ.d()/2.,(p1[0], p1[1])))
				#ent = adoc.CreateCircle2(p1[0]/1000., p1[1]/1000., p1[2]/1000., p2[0]/1000., p2[1]/1000., p2[2]/1000.)
			if points and not OBJ.type()=="POINT":
				PTS = OBJ.meas_points()
				print "dodawanie punktow pomiarowych:"
				for pp in PTS:
					#print (pp[0],pp[1],pp[2])
					if d3d:
						drawing.add(dxf.point((pp[0],pp[1],pp[2])))
					else:
						drawing.add(dxf.point((pp[0],pp[1])))
					
		drawing.save()
Exemple #4
0
 def exportToDXF(self, fileName):
     ''' Export entities to DXF.'''
     drawing = dxf.drawing(fileName)
     for layer in self.layersToImport:
         drawing.add_layer(layer)
     for key in self.points:
         p= self.points[key]
         p1= l.getPos3d()
         layerName= self.labelDict[key]
         drawing.add(dxf.point((p1.x, p1.y), layer=layerName))
     for key in self.lines:
         l= self.lines[key]
         p1= l.getFromPoint()
         p2= l.getToPoint()
         layerName= self.labelDict[key]
         drawing.add(dxf.line((p1.x, p1.y), (p2.x, p2.y), layer=layerName))
     if(len(self.polylines)>0):
         lmsg.warning('Export of polyline objects not implemented yet.')
     drawing.save()
Exemple #5
0
    def encode_feature(self, feature):
        if feature["geometry"]["type"] == "Point":
            self._drawing.add(dxf.point(point=(feature["geometry"]["coordinates"][0],feature["geometry"]["coordinates"][1])))
        
        elif feature["geometry"]["type"] == "LineString":
            polyline= dxf.polyline()
            coords = feature["geometry"]["coordinates"]
            for coord in coords:
                polyline.add_vertex((coord[0], coord[1]))
            self._drawing.add(polyline)

        elif feature["geometry"]["type"] == "Polygon":
            polygon = dxf.polyline()
            
            coords = feature["geometry"]["coordinates"]
            for coord in coords:
                for point in coord:
                    polygon.add_vertex((point[0], point[1]))
                polygon.close()
            self._drawing.add(polygon)
Exemple #6
0
def Plot_to_dxf(filename):

    drawing = dxf.drawing(name=filename)

    for i in Punto.all:
        drawing.modelspace.add(dxf.point((i.X, i.Y, i.Z)))
        drawing.modelspace.add(dxf.text(i.Nombre, insert=(i.X, i.Y), color=2))

    def obtener_vertices(Poligono):
        vertices = []
        puntos_vertices = []
        coordenadas_vertices = []
        for observacion in Poligono.Puntos:
            if observacion.Poligono.lower() == Poligono.Nombre.lower():
                vertices.append(observacion.PO)
        for nombre in vertices:
            for punto in Punto.all:
                if punto.Nombre == nombre:
                    puntos_vertices.append(punto)
        for punto in puntos_vertices:
            coordenadas_vertices.append((punto.X, punto.Y, punto.Z))
        return coordenadas_vertices

    def linetype(objeto):
        lt = ''
        if type(objeto) is PoligonoAuxiliar:
            lt = 'DASHED'
        else:
            lt = 'CONTINUOUS'
        return lt

    for poligono in Poligono.all:

        p = drawing.modelspace.add(
            dxf.polyline(points=obtener_vertices(poligono),
                         linetype=linetype(poligono),
                         layer=poligono.Nombre,
                         color=1))
        p.close()

    drawing.saveas(filename)
Exemple #7
0
    def encode_feature(self, feature):
        if feature["geometry"]["type"] == "Point":
            self._drawing.add(
                dxf.point(point=(feature["geometry"]["coordinates"][0],
                                 feature["geometry"]["coordinates"][1])))

        elif feature["geometry"]["type"] == "LineString":
            polyline = dxf.polyline()
            coords = feature["geometry"]["coordinates"]
            for coord in coords:
                polyline.add_vertex((coord[0], coord[1]))
            self._drawing.add(polyline)

        elif feature["geometry"]["type"] == "Polygon":
            polygon = dxf.polyline()

            coords = feature["geometry"]["coordinates"]
            for coord in coords:
                for point in coord:
                    polygon.add_vertex((point[0], point[1]))
                polygon.close()
            self._drawing.add(polygon)
Exemple #8
0



for i in ppolylines:
    polyline= dxf.polyline(linetype='DOT',color = 256,layer='midPressB')
    polyline.add_vertices( i )
    drawing.add(polyline)
# =============================================================================
#     drawing.save()
#     drawing.add(
#         dxf.polylines(
#             ppoints[i],
#             ppoints[i+1],
#             layer='midPressB',
#             color = 256
#         )
#     )
# =============================================================================
for i in ppoints:
    text = dxf.text('Text', i, height=3, rotation=45,layer ='text' ,color =200 )
    point = dxf.point(i)
    point['layer'] = 'points'
    point['color'] = 100
    point['thickness'] = 3.2
    drawing.add(point)
    drawing.add(text)
drawing.save()


    def render(self):
        data = self.data
        point_layers = {}

        # create the drawing and add layers to it
        drawing = dxf.drawing()
        drawing.add_layer(self.filter_layer_name('objects'))
        drawing.add_layer(self.filter_layer_name('marker'))
        drawing.add_layer(self.filter_layer_name('Mesh'))

        # Add layers from the doncodes
        for l in set([
                self.doncodes["doncodes"][lx]["CAD LAYERS"]
                for lx in self.doncodes["doncodes"]
        ]):
            if l:
                drawing.add_layer(self.filter_layer_name(l))

        # might need custom layers for major/minor contours
        have_contour_names = []
        for x in ["major", "minor"]:
            if self.settings["job"].get("contours") and self.settings["job"][
                    "contours"][x] and self.settings["job"]["contours"][x].get(
                        "layer"):
                drawing.add_layer(
                    self.filter_layer_name(
                        "Contour - " +
                        str(self.settings["job"]["contours"][x].get("layer"))))
                have_contour_names.append(x)

        if len(have_contour_names) < 2:
            # drawing.add_layer(self.filter_layer_name('Contour'))
            drawing.add_layer(self.filter_layer_name('Contour Splines'))
            drawing.add_layer(self.filter_layer_name('Contour Splines Flat'))

        # add the separated codes/shots/rls
        for x in ["Shots", "Rls", "Codes"]:
            for y in ["", "_NC", "_NL"]:
                drawing.add_layer(self.filter_layer_name(x + y))

        #drawing.header['$ANGBASE'] = self.bm["marker_angle"]

        #drawing.header['$UCSORG'] = (0, 0, 0)
        #drawing.header['$UCSXDIR'] = (1, 0, 0)
        #drawing.header['$UCSYDIR'] = (0, 1, 0)

        # set 3D Point
        #drawing.header['$EXTMIN'] = (0, 0, -10)
        #drawing.header['$EXTMAX'] = (1000, 1000, 100)

        # add the mesh
        if self.settings["options"]["threedMesh"] == "1":
            self.render_mesh(drawing)

        #add stringlines to string_lines layer
        for line in data["stringlines"]:
            if len(data["stringlines"][line]) > 1:
                # variable to store stringline colour, thickness etc. to be passed to polyline
                stringline_detail = {}
                first_point = data["stringlines"][line][0]
                ms_layer = first_point["doncode"].get("MS Properties")
                layer_codes = self.doncodes["ms_layers"].get(ms_layer)
                # make sure we have stringline properties in our doncodes array (often blank)
                if layer_codes:
                    # print data["stringlines"][line][0]["code"], ms_layer
                    # print first_point["code"], layer_codes
                    # if we have a special colour
                    if layer_codes.get("Col"):
                        stringline_detail["color"] = int(layer_codes["Col"])
                    # if we have a line weight set
                    if layer_codes.get("Line Weight") and int(
                            layer_codes.get("Line Weight")):
                        stringline_detail["thickness"] = int(
                            layer_codes.get("Line Weight"))
                    # if we have a line style TODO: map these to their actual line styles
                    if layer_codes.get("Line Style") and int(
                            layer_codes.get("Line Style")):
                        stringline_detail["linetype"] = int(
                            layer_codes.get("Line Style"))
                polyline = dxf.polyline(layer=self.filter_layer_name(
                    first_point["doncode"].get("CAD LAYERS")),
                                        **stringline_detail)
                polyline.add_vertices([
                    self.convert_point(p["point"])
                    for p in data["stringlines"][line]
                ])
                drawing.add(polyline)

        # add the regular (original) contour line
        if self.settings["options"]["origContour"] == "1":
            self.render_contour(drawing, data["contour_lines"],
                                lambda p: self.convert_point(
                                    p))  # Line was previously commented.

        # add splines contour line
        if self.settings["options"]["splinesContour"] == "1":
            # splines version
            self.render_contour(drawing, data["contour_splines"],
                                lambda p: self.convert_point(p), " Splines")
            # flat spline version
            self.render_contour(
                drawing, data["contour_splines"],
                lambda p: self.flatten_point(self.convert_point(p)),
                " Splines Flat")

        # loop through the points with 2d objects on them putting Xrefs on the ones that need it
        #print data["objects_2d"]
        for o in data["objects_2d"]:
            # //bush.position.set(objects_2d[o][0],objects_2d[o][1]+0.3,objects_2d[o][2]).multiplyScalar(psu_renderer.SCALE);
            # psu_renderer.generate_obj(bush.clone());
            drawing.add_xref(self.settings["global"].get("export", {}).get(
                "xref_path", "") + o["code"] + ".dwg",
                             insert=self.convert_point(o["point"]),
                             layer=self.filter_layer_name(
                                 o["doncode"].get("CAD LAYERS")))

        # find and add trees to plot and tree schedule
        # create the table for tree information
        tree_table = dxf.table(insert=self.convert_point(
            [self.bounding_box[0][1], 0, self.bounding_box[2][0] - 20]),
                               nrows=len(data["trees"]) + 2,
                               ncols=4)
        tree_table.set_col_width(1, 4)
        tree_table.set_col_width(2, 3)
        tree_table.set_col_width(3, 5)
        # table cell style
        ctext = tree_table.new_cell_style('ctext',
                                          textcolor=7,
                                          textheight=0.5,
                                          halign=dxfwrite.CENTER,
                                          valign=dxfwrite.MIDDLE)
        # table border style
        border = tree_table.new_border_style(color=6, priority=51)
        ctext.set_border_style(border, right=False)
        # table header
        hcell = tree_table.text_cell(0, 0, "SCHEDULE OF TREES")
        hcell.span = (1, 4)
        tree_table.text_cell(1, 1, "DIAMETER", style='ctext')
        tree_table.text_cell(1, 2, "HEIGHT", style='ctext')
        tree_table.text_cell(1, 3, "TYPE", style='ctext')
        for t in range(len(data["trees"])):
            tree = data["trees"][t]
            diameter = tree["tree_details"].get("diameter", None)
            height = tree["tree_details"].get("height", None)
            spread = tree["tree_details"].get("spread", None)
            note = tree["tree_details"].get("note", None)
            blockname = "tree_" + str(t + 1)
            layer = self.filter_layer_name(
                self.doncodes["doncodes"][tree["code"]].get("CAD LAYERS"))
            if diameter or spread:
                tree_block = dxf.block(name=blockname)
                # trunk
                if diameter:
                    tree_block.add(
                        dxf.circle(float(diameter) / 2.0, [0, 0], layer=layer))
                # leaves
                if spread:
                    tree_block.add(
                        dxf.circle(float(spread) / 2.0, [0, 0], layer=layer))
                drawing.blocks.add(tree_block)
                drawing.add(
                    dxf.insert2(blockdef=tree_block,
                                insert=self.convert_point(tree["position"]),
                                layer=layer))
            # table
            # table position is left of bounding box
            tree_table.text_cell(t + 2, 0, "T" + str(t + 1), style='ctext')
            tree_table.text_cell(t + 2,
                                 1,
                                 diameter and diameter or "",
                                 style='ctext')
            tree_table.text_cell(t + 2,
                                 2, (height and height + "m" or ""),
                                 style='ctext')
            tree_table.text_cell(t + 2,
                                 3,
                                 note and note.upper() or "",
                                 style='ctext')
        drawing.add(tree_table)

        if not self.bm.get("fake"):
            drawing.add(
                dxf.point(self.convert_point(self.bm["position"]),
                          layer=self.filter_layer_name(
                              self.doncodes["doncodes"][self.bm["code"]].get(
                                  "CAD LAYERS"))))
            drawing.add(
                dxf.text("BM",
                         self.convert_point(self.bm["position"]),
                         height=0.2,
                         layer=self.filter_layer_name(
                             self.doncodes["doncodes"][self.bm["code"]].get(
                                 "CAD LAYERS"))))

        # loop through the points adding labels to the layer
        seen = []
        for p in data["p"]:
            # uniquely identify this piece of text at this position to prevent duplicates
            text_id = tuple(
                [p["original_code"], p.get("day_id", "")] + p["position"])
            # figure out if we are NL or
            layer_postfix = ""
            for l in ["NL", "NC"]:
                if l in p["extensions"]["function"]:
                    layer_postfix = "_" + l
            # if this isn't a duplicate and isn't a tree
            if not text_id in seen or p["code"] == "TR":
                blockname = 'point_' + str(p["point_id"]) + (
                    p.get("day_id") and "-" + p["day_id"] or "")
                point_block = dxf.block(name=blockname)
                if p.get("force_point_layer"):
                    layer_code = p["force_point_layer"]["code"]
                else:
                    layer_code = p["code"]
                layer = self.filter_layer_name(
                    self.doncodes["doncodes"][layer_code].get("CAD LAYERS"))
                # create a block to unite the various elements of the point
                # for trees we just want to draw their ref
                if p["code"] == "TR":
                    point_block.add(
                        dxf.text(
                            "T" +
                            str([t["point_id"]
                                 for t in data["trees"]].index(p["point_id"]) +
                                1), [0.2, 0.2],
                            height=0.2,
                            layer="Codes" + layer_postfix))
                else:
                    # these codes don't have the original_code text printed on the plot
                    if not p["code"] in ["RC", "LC"]:
                        # everything else gets original code printed
                        point_block.add(
                            dxf.text(p["original_code"] + " (" +
                                     str(p["line_number"]) + ")", (0, 0),
                                     alignpoint=(0, -0.2),
                                     height=0.05,
                                     rotation=-90,
                                     layer="Codes" + layer_postfix,
                                     valign=MIDDLE))
                    if not "NL" in p["extensions"]["function"]:
                        point_block.add(
                            dxf.text("%.2f" % (p["position"][1]), (0, 0),
                                     alignpoint=(0.12, -0.12),
                                     height=0.3,
                                     rotation=-45,
                                     layer="Rls" + layer_postfix,
                                     valign=MIDDLE))
                point_block.add(
                    dxf.point([0, 0], layer="Shots" + layer_postfix))
                drawing.blocks.add(point_block)
                drawing.add(
                    dxf.insert2(blockdef=point_block,
                                insert=self.convert_point(p["position"]),
                                layer=layer))

                # print p["doncode"].get("Draw Cross Hair on Point")
                if self.doncodes["doncodes"][p["code"]].get(
                        'Draw Cross Hair on Point',
                        'n').lower() in ["1", "y", "yes", "true", "x"]:
                    drawing.add_xref(self.settings["global"].get(
                        "export", {}).get("xref_path", "") + "X.dwg",
                                     insert=self.convert_point(p["position"]),
                                     layer="Shots" + layer_postfix)
                seen.append(text_id)

        # save the drawing to the binary blob and then return the DXF code
        # binary blob to pretend to be a file and store our saved DXF
        blob = StringIO()
        drawing.save_to_fileobj(blob)
        return blob.getvalue()
Exemple #10
0
@author: Pedro Medeiros
"""
# Desenhar pontos em dxf
from dxfwrite import DXFEngine as dxf
import pandas as pd
#fname = "Resultados_Anexos"

fname = input("Introduza o nome do ficheiro com as coordenadas dos pontos (sem extensão):")

# Nome dos ficheiros
fnameIn = fname + ".txt"
fnameOut = fname + ".dxf"

# Criação de data frame
df = pd.read_csv(fnameIn, sep=",", delimiter="\t")


drawing = dxf.drawing(fnameOut)
n = df.shape[0]

for i in range(0, n-1):
    x = df.iloc[i, 0]
    y = df.iloc[i, 1]
    drawing.add(dxf.point(point=(x, y)))
drawing.save()

print("\n")
print("\n")
input("Script executado com sucesso. Prima qualquer tecla para terminar")
Exemple #11
0
drawing = dxf.drawing('survey.dxf')
lp=drawing.add_layer('Points')
lp['color']=7
lc=drawing.add_layer('Codes')
lc['color']=7
lc.off()
ln=drawing.add_layer('Numbers')
ln['color']=7
ln.off()
lco=drawing.add_layer('Elevations')
lco['color']=7


for j in range(0,l):
    point = dxf.point((2.0, 2.0))
    point['layer']='Points'
    point['thickness']=7
    point['point']=(rid[k[2]][j],rid[k[1]][j],rid[k[3]][j])
    drawing.add(point)

    text = dxf.text(rid[k[0]][j], insert=(rid[k[2]][j],rid[k[1]][j],rid[k[3]][j]), height=1)
    text['layer']='Numbers'
    drawing.add(text)

    code = dxf.text(rid[k[4]][j], insert=(rid[k[2]][j],rid[k[1]][j],rid[k[3]][j]), height=1)
    code['layer']='Codes'
    drawing.add(code)

    elevation = dxf.text(rid[k[3]][j], insert=(rid[k[2]][j],rid[k[1]][j],rid[k[3]][j]), height=1)
    elevation['layer']='Elevations'
    center_point=(10, 10),
    height=30,
)

# add LINE-entity
drawing.add(dxf.line((0, 0), (10, 0), color=dxfwrite.BYLAYER,
                     layer='dxfwrite'))

# add a CIRCLE-entity
drawing.add(dxf.circle(center=(5, 0), radius=5))

# add an ARC-entity
drawing.add(dxf.arc(center=(5, 0), radius=4, startangle=30, endangle=150))

#add a POINT-entity
drawing.add(dxf.point(point=(1, 1)))

# add a SOLID-entity with 4 points
drawing.add(dxf.solid([(0, 0), (1, 0), (1, 1), (0, 1)], color=2))

# add a SOLID-entity with 3 points
drawing.add(dxf.solid([(0, 1), (1, 1), (1, 2)], color=3))

# add a 3DFACE-entity
drawing.add(dxf.face3d([(5, 5), (6, 5), (6, 6), (5, 6)], color=3))

# add a Trace-entity
drawing.add(dxf.trace([(7, 5), (8, 5), (8, 6), (7, 6)], color=4))

# add a TEXT-entity
drawing.add(dxf.text("Manfred"))
Exemple #13
0
import sys

if len(sys.argv) != 3:
    print "needs 2 args: input file (csv) and outpout file (dxf)"
    sys.exit(-1)

inputFile = sys.argv[1]
outputFile = sys.argv[2]

file = open(inputFile, "rb")
drawing = dxf.drawing(outputFile)
i = 0

try:
    reader = csv.reader(file, delimiter='\t')
    for row in reader:
        if len(row) >= 3:
            text = row[0]
            x = float(row[1])
            y = float(row[2])
            drawing.add(dxf.point((x, y), color=7))
            drawing.add(dxf.text(text, insert=(x, y), color=3, height=100.0))
            i = 1 + i
        else:
            print "len(row)=", len(row)
finally:
    file.close()

drawing.save()
print "Nb Points =", i
Exemple #14
0
 def writeDxf(self, drawing, layerName):
     drawing.add(
         DXFEngine.point((self.coords[0], self.coords[1], self.coords[2]),
                         color=0,
                         layer=layerName))
Exemple #15
0
drawing = dxf.drawing(output_file)
#fout = open(output_file,"w")

# read the adcirc file
n,e,x,y,z,ikle = readAdcirc(adcirc_file)

############################################################
# writing nodes
w = [Percentage(), Bar(), ETA()]

pbar = ProgressBar(widgets=w, max_value=n).start()
print('processing nodes')

# create nodes in the dxf file
for i in range(n):
  drawing.add(dxf.point(point=(x[i],y[i],z[i])))
  pbar.update(i+1)
  
pbar.finish()

############################################################
# writing elements

pbar = ProgressBar(widgets=w, max_value=e).start()
print('processing elements')
# to create elements
for i in range(e):
  poly = dxf.polyline()
  #pface = dxf.polyface()
  # create tupples for each vertex
  v0 = (x[ikle[i,0]],y[ikle[i,0]],z[ikle[i,0]])
Exemple #16
0
                color = indicator % 255,
        )
    
        for s in sub.edges(data = True):
            startPoint = nodeTableReverse[s[0]]
            
            endPoint = nodeTableReverse[s[1]]
            xdiff = startPoint[0] - endPoint[0]
            ydiff = startPoint[1] - endPoint[1]
            angle = 0
            if np.abs(xdiff)> 1e-5:
                angle = np.arctan(ydiff/xdiff)*180/np.pi
            
            middlePoint = [( startPoint[0] + endPoint[0] ) /2.,( startPoint[1] + endPoint[1] ) /2.]
            line = dxf.line(startPoint, endPoint,layer ='subG%s'% indicator )
            text = dxf.text('pipe%s'%  str(s[2]['ID']), middlePoint, height=0.2, rotation=angle,layer ='pipeLabel'  )
            text['color'] = 0
            
            drawing.add(line)
            drawing.add(text)
        
    
        for i in sub.nodes:
            text = dxf.text(i, nodeTableReverse[i], height=0.05, rotation=0,layer ='subG%s'% indicator  )
            point = dxf.point(nodeTableReverse[i], layer ='points'  )
            point['color'] = 250
            drawing.add(text)
            drawing.add(point)
        indicator += 1
    drawing.save()
Exemple #17
0
    )

# add LINE-entity
drawing.add(dxf.line((0,0),( 10,0),
    color=dxfwrite.BYLAYER,
    layer='dxfwrite'
))

# add a CIRCLE-entity
drawing.add(dxf.circle(center=(5,0), radius=5))

# add an ARC-entity
drawing.add(dxf.arc(center=(5,0), radius=4, startangle=30, endangle=150))

#add a POINT-entity
drawing.add(dxf.point(point=(1,1)))

# add a SOLID-entity with 4 points
drawing.add(dxf.solid([(0,0), (1,0), (1,1), (0,1)], color=2))

# add a SOLID-entity with 3 points
drawing.add(dxf.solid([(0,1), (1,1), (1,2)], color=3))

# add a 3DFACE-entity
drawing.add(dxf.face3d([(5,5), (6,5), (6,6), (5,6)], color=3))

# add a Trace-entity
drawing.add(dxf.trace([(7,5), (8,5), (8,6), (7,6)], color=4))

# add a TEXT-entity
drawing.add(dxf.text("Manfred"))
Exemple #18
0
drawing = dxf.drawing(name + '.dxf')

for x in range(0, len):
    cmd = params[x].split('(')[0]
    p = params[x].split('(')[1].split(')')[0].split(',')
    if cmd == 'line':
        drawing.add(
            dxf.line((float(p[0]), float(p[1])), (float(p[2]), float(p[3]))))
    elif cmd == 'circle':
        circle = dxf.circle(float(p[0]), (float(p[1]), float(p[2])))
        drawing.add(circle)
    elif cmd == 'ellipse':
        circle = dxf.circle(float(p[0]), (float(p[1]), float(p[2])))
        drawing.add(circle)
    elif cmd == 'point':
        point = dxf.point((float(p[1]), float(p[2])))
        drawing.add(point)
    elif cmd == 'rect':

        drawing.add(
            dxf.line((float(p[0]), float(p[1])),
                     (float(p[0]) + float(p[2]), float(p[1]))))

        drawing.add(
            dxf.line((float(p[0]) + float(p[2]), float(p[1])),
                     (float(p[0]) + float(p[2]), float(p[1]) + float(p[3]))))
        drawing.add(
            dxf.line((float(p[0]) + float(p[2]), float(p[1]) + float(p[3])),
                     (float(p[0]), float(p[1]) + float(p[3]))))

        drawing.add(
Exemple #19
0
    def __init__(self,filename):
        self.constants = {}
        self.load_file(filename)
        #Move to the first target...
        
    def load_file(self,filename):
        self.filename = filename
        file = os.open(filename,os.O_RDONLY)
        self.map = mmap.mmap(file,0,prot=mmap.PROT_READ)
        
    def get_next_point(self):
        return self.map.readline().split()
if __name__ == "__main__":
    import sys
    #filename = sys.argv[1]
    filename = "joe.txt"
    pcl_file = pcl_parser(filename)

    a = pcl_file.get_next_point()
    point = (float(a[0]), float(a[1]),  float(a[2]))

    drawing = dxf.drawing('test.dxf')
    drawing.add_layer('TEXTLAYER', color=2)

    while a != []:
        point = (float(a[0]), float(a[1]),  float(a[2]))
        drawing.add(dxf.point(point))
        a = pcl_file.get_next_point()
        
    drawing.save()    
Exemple #20
0
        self.load_file(filename)
        #Move to the first target...

    def load_file(self, filename):
        self.filename = filename
        file = os.open(filename, os.O_RDONLY)
        self.map = mmap.mmap(file, 0, prot=mmap.PROT_READ)

    def get_next_point(self):
        return self.map.readline().split()


if __name__ == "__main__":
    import sys
    #filename = sys.argv[1]
    filename = "joe.txt"
    pcl_file = pcl_parser(filename)

    a = pcl_file.get_next_point()
    point = (float(a[0]), float(a[1]), float(a[2]))

    drawing = dxf.drawing('test.dxf')
    drawing.add_layer('TEXTLAYER', color=2)

    while a != []:
        point = (float(a[0]), float(a[1]), float(a[2]))
        drawing.add(dxf.point(point))
        a = pcl_file.get_next_point()

    drawing.save()
Exemple #21
0
Observacion6 = Esfericas('2','2.4','Arbol','Poligono1',25,50, 88)
Observacion7 = Taquimetria('2', '2.5', 'Acera', 'Poligono1', 30, 2, 1.5, 1, 88)
Observacion8 = Taquimetria3D('2', '2.6', 'Acera', 'Poligono1', 45, 2, 1.5, 1, 88, 1.45)
Observacion9 = Cartesiana_relativa('2', '2.7', 'Esquina', 10, 5, 2)

Punto('0',0 , 0, 0)

for i in Observacion.all:
    Totales(i)
    
Plot()

drawing = dxf.drawing(name='test.dxf')

for i in Punto.all:
    drawing.modelspace.add(dxf.point((i.X, i.Y, i.Z)))
    drawing.modelspace.add(dxf.text(i.Nombre, insert=(i.X, i.Y), color=2))


Ancho_hoja = 0.2794
Largo_hoja = 0.2159
#Cajetin
drawing.paperspace.add(dxf.viewport(center_point=(Ancho_hoja/2, Largo_hoja/2+0.02),
        # viewport width in paper space
        width=Largo_hoja-0.04,
        # viewport height in paper space
        height=Ancho_hoja-0.02))


#set value
drawing.header['$ANGBASE'] = 30
Exemple #22
0
drawing = dxf.drawing(output_file)
#fout = open(output_file,"w")

# read the adcirc file
n,e,x,y,z,ikle = readAdcirc(adcirc_file)

############################################################
# writing nodes
w = [Percentage(), Bar(), ETA()]

pbar = ProgressBar(widgets=w, max_value=n).start()
print('processing nodes')

# create nodes in the dxf file
for i in range(n):
	drawing.add(dxf.point(point=(x[i],y[i],z[i])))
	pbar.update(i+1)
	
pbar.finish()

############################################################
# writing elements

pbar = ProgressBar(widgets=w, max_value=e).start()
print('processing elements')
# to create elements
for i in range(e):
	poly = dxf.polyline()
	#pface = dxf.polyface()
	# create tupples for each vertex
	v0 = (x[ikle[i,0]],y[ikle[i,0]],z[ikle[i,0]])