Jump to content

line at both ends of the extension


highflybird

Recommended Posts

Try the attached lisp routine written by ASMI and originally posted here at CADTutor. I'm not sure of the date. The command to type in after loading the routine is blen.

 

Note: This routine will lengthen or shorten a line at both ends. User's choice.

 

Test.lsp

Link to comment
Share on other sites

Hi

multi-select lines , Enter the distance, line at both ends of the lengthen.

Thanks for any help.

[ATTACH=CONFIG]50379[/ATTACH]

Do you mean both sides?

sub function:

;For Extension of linear (lines & align Dimension only)
;hanhphuc 2014
argument:
_e= ename
ex= extension. 'REAL
id= dxf index. eg: '(10 11)

(defun +exlin (_e ex id / l ep a d) 
 (if (and id (= (length id) 2)) ; index list only limited for 2
   (progn (setq l  (entget _e)
	 ep (mapcar ''((x) (cdr (assoc x l))) id)
	 a  (angle (car ep) (cadr ep))
	 d  (apply 'distance ep)
	 ) ;_ end of setq
   (mapcar ''((u v)(entmod [color="blue"] (setq l [/color](subst (cons u v) (assoc u l) l)))) ; <--updated
	   id
	   (mapcar ''((x) (polar (mapcar ''((a b) (/ (+ a b) 2.)) (car ep) (cadr ep)) x (+ (/ d 2.) ex)))
		   (list a (+ a pi))
		   ) ;_ end of mapcar
	   ) ;_ end of mapcar
   ) ;_ end of progn
   ) ;_ end of if
 ) ;_ end of defun

;Example call:
;(+exlin (car(entsel)) 1.0[color="red"] '(10 11)[/color]) <--- click line
;(+exlin (car(entsel)) 1.0[color="red"] '(13 14)[/color]) <--- click aligned dimension


 

Test:


(if (not *dist*)(setq *dist* 1.0))

(defun c:EXLIN (/ *error* ext e ve os ad)
 (defun *error* (msg)
   (if	(not (wcmatch (strcase msg) "*CANCEL*,*EXIT*"))
     (princ (strcat "\nError: " msg))
     ) ;_ end of if
   (princ)
   ) ;_ end of defun
 (setq	ext (getdist (strcat "\nEnter extension? <" (rtos *dist* 2) "> : "))
os  (getvar "osmode")
) ;_ end of setq
 (if (not ext)
   (setq ext *dist*)
   (setq *dist* ext)
   ) ;_ end of if
 (setvar "osmode" 0)
 (while (and (setq e (entsel "\nPick Aligned Dimension: "))
      (setq ve (vlax-ename->vla-object (car e))
	    ad (vla-get-objectname ve)
	    ) ;_ end of setq
      ) ;_ end of and
   (cond ((apply 'or (mapcar ''(($) (wcmatch ad $)) '("*AcDbAlignedD*" "*AcDbRotatedD*")))
   (+exlin (car e) ext '(13 14))
   ) 
  ((wcmatch ad "*AcDbLine*") (+exlin (car e) ext '(10 11))) ;(+rdim (car e) ext)
  (t nil)
  ) ;_ end of cond
   ) ;_ end of while
 (setvar "osmode" os)
 ) ;_ end of defun


http://www.cadtutor.net/forum/showthread.php?88181-line-at-both-ends-of-the-extension
(princ "\nhanhphuc 2014. Extension Dimension. Command: EXLIN")
(princ)

Edited by hanhphuc
Link to comment
Share on other sites

My offer with simple thing :)

 

(defun c:Test (/ ss d i e 1p 2p a)
 ;;    Tharwat 14.Aug.2014        ;;
 (if (and (setq d (getdist "\n Specify distance to add :")) (setq ss (ssget "_:L" '((0 . "LINE")))))
   (repeat (setq i (sslength ss))
     (setq e  (entget (ssname ss (setq i (1- i))))
           1p (cdr (assoc 10 e))
           2p (cdr (assoc 11 e))
           a  (angle 1p 2p)
     )
     (setq e (subst (cons 10 (polar 2p a d)) (assoc 10 e) e)
           e (subst (cons 11 (polar 1p (+ a pi) d)) (assoc 11 e) e)
     )
     (entmod e)
   )
 )
 (princ)
)

Link to comment
Share on other sites

Try the attached lisp routine written by ASMI and originally posted here at CADTutor. I'm not sure of the date. The command to type in after loading the routine is blen.

 

Note: This routine will lengthen or shorten a line at both ends. User's choice.

 

[ATTACH]50385[/ATTACH]

 

Thanks Remark , I test your code in Acad2007 , It's OK! can both ends, But I test in Acad2010 , only one end .Puzzled!

Link to comment
Share on other sites

My offer with simple thing :)

 

(defun c:Test (/ ss d i e 1p 2p a)
 ;;    Tharwat 14.Aug.2014        ;;
 (if (and (setq d (getdist "\n Specify distance to add :")) (setq ss (ssget "_:L" '((0 . "LINE")))))
   (repeat (setq i (sslength ss))
     (setq e  (entget (ssname ss (setq i (1- i))))
           1p (cdr (assoc 10 e))
           2p (cdr (assoc 11 e))
           a  (angle 1p 2p)
     )
     (setq e (subst (cons 10 (polar 2p a d)) (assoc 10 e) e)
           e (subst (cons 11 (polar 1p (+ a pi) d)) (assoc 11 e) e)
     )
     (entmod e)
   )
 )
 (princ)
)

 

Tharwat , Thanks. Long time no see.

Your routine very good! nice!

Link to comment
Share on other sites

Yes, he means both ends.

 

@hi ReMark thanks , i was confused whether pick line or dimension, then i made both.:)

& Tharwat

mine the dimension has become non-associative, is it normal?

Link to comment
Share on other sites

I did not interpret the original post to include the dimension. I think the OP put it there to demonstrate the "before" and "after" line lengths.

 

The routine I posted, written by ASMI, was tested using AutoCAD 2015 and it worked.

 

Note that until I posted the first response no one else had offered a solution. Now the OP has more than one. Nice.

Link to comment
Share on other sites

Do you mean both sides?

 

Yes ,both sides.

Thanks for your code. It's OK! but why dimension did not follow the lines ? Remark and Tharwat's code can!

Link to comment
Share on other sites

Tharwat , Thanks. Long time no see.

Your routine very good! nice!

 

Excellent , you are welcome :)

 

I am daily trolling AutoLISP forums and specially CADTutor ;)

 

 

& Tharwat

mine the dimension has become non-associative, is it normal?

 

I think no , your dimensions that associated with the modified lines should be changed according to new changes on lines if they are associated dimensions .

A little modification on the codes to avoid an upside down of dimensions ;)

 

(defun c:Test (/ ss d i e 1p 2p a)
 ;;    Tharwat 14.Aug.2014        ;;
 (if (and (setq d (getdist "\n Specify distance to add :")) (setq ss (ssget "_:L" '((0 . "LINE")))))
   (repeat (setq i (sslength ss))
     (setq e  (entget (ssname ss (setq i (1- i))))
           1p (cdr (assoc 10 e))
           2p (cdr (assoc 11 e))
           a  (angle 1p 2p)
     )
     (setq e (subst (cons 10 (polar 1p (+ a pi) d)) (assoc 10 e) e)
           e (subst (cons 11 (polar 2p a d)) (assoc 11 e) e)
     )
     (entmod e)
   )
 )
 (princ)
)

Link to comment
Share on other sites

mine the dimension has become non-associative, is it normal?

 

Yes, it's normal - you modified dimension, so it now has no valid association entity to take association from...

Link to comment
Share on other sites

Yes ,both sides.

Thanks for your code. It's OK! but why dimension did not follow the lines ? Remark and Tharwat's code can!

 

i figured out..

inside sub-function


;This was incorrect..
(mapcar ''((u v) [color="red"](setq l[/color] (entmod  (subst (cons u v) (assoc u l) l)))) ....

;should be this
(mapcar ''((u v) (entmod [color="red"](setq l [/color](subst (cons u v) (assoc u l) l)))) ....

 

Thank you :-)

Link to comment
Share on other sites

i figured out..

inside sub-function


;This was incorrect..
(mapcar ''((u v) [color="red"](setq l[/color] (entmod  (subst (cons u v) (assoc u l) l)))) ....

;should be this
(mapcar ''((u v) (entmod [color="red"](setq l [/color](subst (cons u v) (assoc u l) l)))) ....

 

Thank you :-)

 

Thanks hanhphuc , It's the same too.

Link to comment
Share on other sites

Yes, it's normal - you modified dimension, so it now has no valid association entity to take association from...

Thank you marko for the info.

for line it should be associative, it's wield why not function by others?

 

EXLIN1.gif

Edited by hanhphuc
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...