AutoCAD Visual LISP / AutoLISP :: Detect Intersection Of Line And Circle?
May 17, 2013How do you detect the intersection of a line and circle or arc.
View 1 RepliesHow do you detect the intersection of a line and circle or arc.
View 1 RepliesI was looking for a post on the subject of line and circle intersections and found one that Bill Z had posted. I decided to incorperate one of the replies into my own code. In particular Luis Esquivel's code. With some minor modifications I was able to add the onseg argument that extends intersection points for the line to the circle. I also modified it to return only one point or two points depending on the line and circle supplied and the onseg argument. It seems to work great.
; test function
(defun c:go ( / )
(ed_init)
(while
(or
(not (setq ent (entsel "
[code].....
I need a lisp which is i can draw a line or pline with circle in every 30 meters ( circle diameter and total line or pline length will be optional )
View 6 Replies View RelatedAny way to detect of there are objects currently selected using Autolisp, visual lisp or even VBA. I would like to be able to do something using that as a conditional, so that (assuming the hypothetical variable isSelected is an on/off indicator of whether or not something is selected) I can code something like this:
(if (isSelected) (...))
I want to code this lisp. The problem which I face is, In some drawings which come from the client, there are a lot of blocks.
I want to detect the blocks which has no sub-entities (but attribute) and add a rectangle inside this block, If it is an attribute add a line from 0,0, to insertpoint of attribute.
I need ot append events when the dimstyle is change using the AutoCAD dimstyle popup list, but don't know which reactoer to use. I tried with Comman begin and end, and Sysvawill change and changed, but they don't detect the dimstyle changes.
View 2 Replies View RelatedI'm putting together a simple lisp routine to issue bound, purged drawings.
I have code that will do the binding & purging but need handling the saving.
This is my approach :
(1) ask the user to save the drawing using this line (command "_saveas" "" "~")
(2) run a subroutine that binds xrefs etc (this works ok)
(3) run the QSAVE command
Trouble is, if the user cancels or hits escape during the SAVEAS command the subroutine & QSAVE will still run, overwriting the current drawing. How do I handle this scenario? Or should my appoach be different?
I tried to adapt the code provided by scottbolton in the "Insert block at intersection" thread to suit my needs. I would like to be able to enter a block name, and let that block be inserted at intersection points.
But i keep getting a DXF error.
(defun c:sbx (/)
(vl-load-com)
;;;define block used in program
(setq bloktype (getvar "USERS5"))
(prompt "asiswaarde: ")
[code]......
how can you get the last point you picked on a Circle because I was going to run the TTR and use the tanget command and have it exit and I need to get the point I pick on the circle
View 7 Replies View RelatedRoutine that will draw a insulation hatch around a circle?
View 9 Replies View RelatedCan a AutoLISP command be written to read an attribute in a block and draw a circle with the attribute as the diameter using variables? The appilcation is taking the diameter of a tree trunk (the attribute), multipling by 12, and drawing the canopy circle on hundreds of those blocks. So the circles drawn will vary in size.
Not sure how this could be set up, i'm not familiar with LISP writing at all.
1) Read block, single, mulitple or definition?
2) Read Attribute
3) Varaible of attribute, (attribute is an inch measurement...it needs to be multipled by 12 to get feet for final use as circle diameter drawn)
4) Draw circle, variable, with diameter coming from attribute variable (attribute in inches that is multipled by 12)
5) Center point or circle to be block's base point
I´m triyng to do a autolisp routine to calculate the perimeter of a drawing with several entities like arc, polyline, spline, lines and circles.
In the web i found out a autolisp routine that calculate this but it doesnt recognizes circles.
I need that the circles can be recognized, does some one knows how i can do that?
I have a window schedule lisp routine that places a 6-sided polygon around text that label each window. I want to change the code so that its a circle instead of a polygon. Here is the code line that needs to be modified:
(command "polygon" "6" "fro" (cdr (assoc 10 (entget templine)))(strcat "@38,-" (rtos (+ (* linecount 18) 14) 2 0)) "C" "6")
You have a dwg with multiple sets of different blocks and a circle you want to place on the insert point of each set blocks.
You select the circle then select one of the blocks in the set and the circle is placed on the insert point of each of the blocks in that set. It would save time from doing it manually and save on mistakes.
I'm trying to write a lisp routine to create a two line MLEADER but i can only get one line of text. Creating the MLEADER manually from the command line i just have to hit enter after the first line of text to add a second line. How would i do this in a lisp routine?
View 2 Replies View RelatedI'm trying to change a routine i just wrote that draws 3d pipes. I wanted to make it so that when a user selects the beginning point and ending point of the pipe, the LISP changes the ucs to that vector, draws the circle at the beginning point and extrudes it to the second point.
It actually works great except when the ucs changes, so do my user points because of teh origin change. Is there a better way I might get this to do what I wnat it to?
(setq ip (getpoint "
Pick First Point:"))(setq ep (getpoint "
Pick Second Point:"))(command ".ucs" "za" ip ep)(setvar "osmode" 0)(command ".circle" ip "d" od)(command ".extrude" (entlast) "" (distance ip ep))(command ".ucs" "w")(setvar "osmode" oldsnap))
How to distribute object (circle) in selection of great number of points?
View 5 Replies View RelatedI am trying to draw a line between two lines and I put together the following. It works great if the start/end points are perpendicular to each other. How do I solve if line one start point is in a positive direction and line two is in a negative direction?
(defun c:test ()
(setq L1 (car (entsel "
Select the first line: "))
L2 (car (entsel "
Select the second line: "))
)
[code]....
I am having a problem with starts and ends of lines. I have draw two lines, end of first is start of second. The problem is because, (cdr (assoc 11 (entget line1))) and (cdr (assoc 10 (entget line2))), somehow, are not the same,
(= (cdr (assoc 11 (entget line1))) (cdr (assoc 10 (entget line2))))
is returning nil, what is so confusing to me is that:
(=(nth 0(cdr (assoc 11 (entget line1)))) (nth 0(cdr (assoc 10 (entget line2)))))
is returning true, the same is for y and z coordinates.
I need to check x y and z coordinates, for this type of problem...
I need to place a circle, of a user-defined radius, as a marker at the endpoints of all lines in a drawing. how to accomplish this using lisp? It doesn't matter if they overlap; I can use OVERKILL to delete those objects.
I started the code with:
(defun c:cmark ()
(setq crad (getdist "
Specify radius: "))
)
But don't know how to cycle through the objects, determine the end points of lines only.
Is there any simple code for to sum length of lines which is i am choosing and copying result to chosen attribute tag ?
View 1 Replies View RelatedHow do I select the layer in which I want to draw?
for example i draw two line and Each of them has to be in different layer.
How do I select the layer which I want to draw?
There are many lisp that draw offset line but what about opposite way , I have wall of double line i need to delete one of them let's say inside wall line .
why i need to do this usually when i tracing in external program like autocad architecture or Revit or archicad i just need outline of exterior and interior walls !.
is there way that can delete the offset line ?(or within range predefined in lisp to prevent interfering of lines deletion).
I have little Autolisp experience, what I need is a lisp routine that will divide a 3D Poly line to say about 1000 points and add index to the points from the start of the line to the end of the line. It is very important that the index be from the start to the end of the line, because we extract the info to excel and then use the x,y and z co-ordinate of the points on our hydraulic analysis program. We need to have the index and the x, y and z co-ordinates on our Excel sheet sorted by index and not by x, y and z.
To be more clear the 3D poly is a pipeline profile so we need to have the points in order by index and not by x, y and z.
Is it possible to control the UCS without using the command line? I'd like to access it and control it with vlisp much the same way I can access DXF groups and manipulate insertions. Seems like it should be possible to play with it's definition inside the object model.
View 5 Replies View RelatedI need lisp that do a line between 4 lines.
View 7 Replies View RelatedI have a custom command that I can initiate (c:TxtE). The function starts running but I need to begin adding several inputs at the command line following this. (ex: "4" "all" "" "oldtext" "newtext"). How do i do that within lisp once the custom command has already begun? If I need to modify the function how would i pass all these as optional type variables?
View 7 Replies View RelatedSomehow, I manage to turn of one variable that display errors on command line.
For example:
(seq a 6)
suppose to return, on command line, something like:
error no function definition: SEQ
I've written my first little Lisp function.What it's for is drawing a simple borehole profile that can then be used to draw stylized cross sections on top of it.
Upon start the lisp, pick a point on screen (to get the X coordinate [x1 below]), then enter ground level at the command line [g1 below], then enter as many thicknesses as are present in the borehole log (will vary, but typically between 3-12). These I added to a list, because that seemed to make sense when I did it.
What I want it to do then is draw a pline from x1, g1 down to the next point (x1,g1 minus the 1st thickness), then the next (x1,g1 minus the 2nd thickness) etc., to the bottom of the borehole.
Then my CAD guys can sit there, and using the borehole logs, enter the values of the boreholes and it draws them on the screen, making it easy to join th dots.
It might be good if it placed a Acad point at each point as well, but I'm not overly bothered about that at the minute.
Here's my attempt so far.
(prompt "Type 'e1' to run...")
(defun c:e1 ( / )
(command "graphscr") (setq x1 (getpoint "
Pick insertion point:")) (setq x1a (car x1))
(initget (+ 1 2 4)) (setq g1 (getreal "
Enter ground elevation: "))
(initget (+ 1 2 2)) (setq lvllist nil ) (while (setq lvl (getreal "
Enter layer thickness <Exit>: ")) (setq lvlList (append lvllist (list lvl))) )
(princ) )
I am trying to create a report of line lengths based on linetype.
I have built a list that looks like this...
(("CUT4SS" . 859.566) ("CUT4SS" . 862.231) ("CUT4SS" . 927.651) ("CUT6SS" . 1158.48) ("CUT6SS" . 509.903) ("CUT6SS" . 2840.31) ("CUT4SS" . 967.76) ("CUT4SS" . 508.73) ("CUT4SS" . 111.065) ("CUT4SS" . 483.216))
I want to take this list and create a function to create a list of total lengths i.e. the CDR's.
(("CUT6SS" .total length)("CUT4SS" . total length))
There is a very complecated drawing. Texts are on a line and crossing a line or something like that. Some texts has insertion points on the line. When the line is selected by LISP, only the specific texts with insertion points on the line are selected. Does it make sence?
View 8 Replies View Related