You are here:

AutoCAD/Breaking lines (special)

Advertisement


Question
Hello,

My English is not perfect, but I will try to be as clear as I can.
So my task is to make an Autolisp program, which would cut any line into 'n' pieces in this way:

L=n^2 (n=1,2,3...)  <- L here is the lenght of small piece.

Say I draw a line which has a lenght of 110. Then this program has to cut it in 6 shorter lines each of it should have lenght of 1*1=1,2*2=4,3*3=9,4*4=16,5*5=25,6*6=36. Total we get lenght of 91, and this program should cut the rest, because (110-91)<(7*7=49).
I wrote a code which draws a line, but i have no idea, how should I write a 'command break' thing, which would be able to cut what I need.

Answer
is there empty space between the lines? or do the endpoints match?
if there is empty space, put in a circle where you want the breaks and trim the line inside of it, then erase the circle.
you might need to set the pickbox quite small to get it if you are zoomed out.
if the breakpoints match the endpoints, you would probably be better off drawing the little line segments manually and calculate the endpoints with the polar function.

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scott Cook

Expertise

I`ve been using AutoCAD since 1987 and programming AutoLISP nearly as long. I can answer questions about programming AutoCAD (except ARX) and production enhancement techniques. I cannot answer questions about AutoCAD crashes or DWG corruption. AutoCAD PROGRAMMING (menus, lisp) related questions only!

Experience

Since 1987. Author of Plot2000 software for for AutoCAD, http://www.plot2000.com. PROGRAMMING QUESTIONS ONLY PLEASE. Questions that are NOT related to programming or AutoCAD customization (menus and lisp only please) are outside the scope of my volunteer services and will NOT BE ANSWERED.

©2012 About.com, a part of The New York Times Company. All rights reserved.