19 JAN,2013


Today i made scripts in Python.The following link is useful to learn Python concepts.

http://en.wikibooks.org/wiki/Python_Programming/Print_version

I am trying to make a flower.dxf file by creating Python script that automatically generates coordinates file.To some extent it is done but even its need modifications.

Suppose we want to create a .dxf file from .py script, it is done in two steps:

1.Create a1.py file.

#!/usr/bin/env python

from math import *
start_angle=0
end_angle=360
num_parts=360
r=3
temp=(end_angle – start_angle)/num_parts
#print “Circle with radius “,r,”,1,3″#
for i in range(0,num_parts):
    x=r*cos(radians(start_angle + i*temp))
    y=r*sin(radians(start_angle + i*temp))
    #print “(“,x,”,”,y,”)”#
    print x,”,”,y
0,0
start_angle=0
end_angle=360
num_parts=360
r=5
temp=(end_angle – start_angle)/num_parts
#print “Circle with radius “,r,”,1,3″#
for i in range(0,num_parts):
    x=r*cos(radians(start_angle + i*temp))
    y=r*sin(radians(start_angle + i*temp))
    #print “(“,x,”,”,y,”)”#
    print x,”,”,y

then assigned permissions

$chmod ugo+rwx

Now run Python script, it generates a1.txt file

$./a1.py > a1.txt

2. Create a1.dxf file

$python text_to_dxf.py a1.txt a1.dxf

We can open .dxf file in LibreCad.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s