![]() |
|
|||||||
| AutoLISP Ask questions, give examples or troubleshoot your lisp programs. Feel free to post your code here (NO commercial adversiting). |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
Hi Carl,
how about a function in the lisp program to plot a cross on the rect after I select it so that I can snap on to it easier. Thanks Regards, kel be |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
This one returns center point of rectangle. Call with 'rmp while drawing/stretching.
You may want to rename it for easier keystrokes. Code:
(defun c:rmp ()
(setq epick (car (entsel "Pick rectangle: ")))
(setq ed (entget epick))
(if (= "LWPOLYLINE" (cdr (assoc 0 ed)))
(progn
(setq VertList (cdrs 10 ed))
(setq vertlist (cdr Vertlist));strip first gc10
(setq pt1 (nth 0 vertlist))
(setq pt2 (nth 2 vertlist))
(setq PtWorld
(mapcar '(lambda (x)
(/ x 2)
)
(mapcar '+ Pt1 Pt2)
)
)
(trans PtWorld 0 1) )
nil;if not a lwpolyline
)
)
;;-------------------------
(defun cdrs (key lst / pair rtn);;M. Puckett
(while (setq pair (assoc key lst))
(setq rtn (cons (cdr pair) rtn)
lst (cdr (member pair lst))
)
)
(reverse rtn)
)
Last edited by CarlAK; 02-10-2010 at 02:13 PM. Reason: Update code for UCS use |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
Hi Carl,
thanks for the input. Its a bit time consuming but its better than before. I will still need to find a faster way later on. Anyway thank you very much for your help. Regards kel be |
|
|
|
|
|
#14 | |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
Quote:
why is that the center point of the rect is not correct if the rect is not horizontal? (the rect is rotated at an angle say 5 deg.) Thanks and Best Regards kel be |
|
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
Not sure why center is not correct, I tried simple rectangle rotate & it seems to work.
now if you rotate the UCS, yes that would cause a problem. The code above was fixed to convert World to UCS coordinates, using the 'trans' function. the following was replaced: (mapcar '(lambda (x) (/ x 2) ) (mapcar '+ Pt1 Pt2) ) -with- Code:
(setq PtWorld
(mapcar '(lambda (x)
(/ x 2)
)
(mapcar '+ Pt1 Pt2)
)
)
(trans PtWorld 0 1)
Last edited by CarlAK; 02-10-2010 at 02:16 PM. Reason: **refered to updated code** |
|
|
|
|
|
#16 |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
Hi Carl,
Thanks for the feedback. It works just as what I expected. Will try out on more examples later. See you.... Regards. kel be |
|
|
|
|
|
#17 | |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
Quote:
If the lines are not filled with hatch (becomes two single line) how do you change the autolisp program (attached) to draw a line between the 2 single line. Thanks. Regards kel be |
|
|
|
|
|
|
#18 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
Would not be easy to change the routine which is set up to recognize hatch geometry, to also recognize an assortment of lines. If user would choose "hatch" or "lines", then pick 2 lines at a time, that would be a fairly simple change. It would take some time to write the code to sort a group of lines, determine how to pair them up for drawing a midline. I would leave that up to you or some other volunteer
|
|
|
|
|
|
#19 |
|
Junior Member
Join Date: Feb 2010
Posts: 14
|
HI Clark,
thanks for the prompt reply. Appreciate your feedback. I have a simple lisp program that needs to select the 2 lines manually to draw the mid line (see attached file). What if we specify a condition that thickness of the line must meet a certain criteria for example not more than a certain value, then is it possible to group them? Just an idea. Thanks and Regards kel be |
|
|
|
|
|
#20 |
|
Senior Member
Join Date: Jan 2009
Location: Anchorage, Alaska
Posts: 203
|
I ran your routine and it works OK - but I had to turn off osnaps. Also if lines are drawn in opposite directions it didn't work correctly.
You could use a closeness tolerance like you suggest, and only draw midlines for lines within that tolerance. If lines are always about the same length, you could compare midpoints for the spacing tolerance. So perhaps make a selection set; and make a list of midpoint coordinates. Compare first midpoint to each other to find one within the tolerance. call line-drawing subroutine for 2 lines. remove lines from selection set. If no line meets tolerance, remove just that one line from set. Repeat until no further "matches". |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|