How do you convert Matlab data into a DXF hole pattern?

3 views (last 30 days)
I am currently working on a project that I will need to have professionally water-jetted. Because of the large number of holes required, I cannot generate a DXF file using a standard CAD program on my computer. I was able to generate the pattern I want easily enough, but can't seem to get the DXF conversion portion correct. I have used related posts on this subject but am at a loss as to where I went wrong. Thanks in advance for any help.
%Fibonacci hole pattern calculator
n=1:13000; %quantity larger than total amount of holes
dmin=.18; %min spacing between holes
D=18; %Max diamter
off=.3; %edge offset
rmax=(D/2)-off;%outer radius of pattern
rmin=.75; %min inner radius
Phi=137.50776*pi/180;
rh=.0625; %radius of hole
% constant to mulitply r by.^-1
c=dmin/sqrt((sqrt(n(3))*cos(Phi*3)-sqrt(n(1))*cos(Phi))+(sqrt(n(3))*sin(Phi*3)-sqrt(n(1))*sin(Phi)))*(.17/.207);
rtemp=c.*sqrt(n);
[j i]=find(rtemp>rmax);%find r to satisfy rmax. j=junk
[j k]=find(rtemp<rmin);%r to satisfy rmin biggest k =start of pattern
r=rtemp(length(k):i-1);
j=length(k):(i-1);
phi=137.50776*pi/180*j;% irrational golden ratio angle approx.
x=r.*cos(phi); % main equation
y=r.*sin(phi);
a=(2*pi/length(j)).*j; %alpha for circle
x2=(D/2).*sin(a);% x and y for circle
y2=(D/2).*cos(a);
%Start DXF portion
fullname=sprintf('pat.dxf');
fid=fopen(fullname,'w');
fprintf(fid,'0\n SECTION\n 2\n ENTITIES\n');
for a=1:length(x)-1
fprintf(fid,'0\n CIRCLE\n 8\n 0\n');
fprintf(fid, '10\n %f\n 20\n %f\n 30\n 0.0\n 40\n .0625\n ', x(a),y(a));
end
fprintf(fid,'endsec\n 0\nEOF\n');
fclose(fid);

Answers (0)

Categories

Find more on Electrical Block Libraries in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!