eyal Posted April 13, 2017 Posted April 13, 2017 Hello everyone, I have this code by Ranjit: (defun c:edb () (c:ebd)) (defun c:ebd ( / *error* of undo doc ss ) ;Ekv Both (defun *error* ( msg ) (and undo (vla-EndUndomark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (if (and (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE"))) (setq of (getdist "\nSpecify Offset Distance: "))) (progn (setq undo (not (vla-StartUndomark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))))) (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc)) (mapcar (function (lambda (o) (vl-catch-all-apply (function vla-offset) (list obj o)))) (list of (- of)))(vla-delete obj)) (setq undo (vla-EndUndoMark doc)))) (princ) ) If you click on a line and specify a distance, it draws offset lines in both sides with the specified distance and erases the original line. I want to change the code so it will keep the line but will change it to center line with another layer called centerline in red. and instead of drawing lines it will draw construction lines. http://imgur.com/a/J1q0p Quote
ccowgill Posted April 13, 2017 Posted April 13, 2017 I'd take a look at Lee Mac's Double Offset Command. I know it has options, not sure if it has one to change the centerline layer. http://www.lee-mac.com/doubleoffset.html Quote
eyal Posted April 13, 2017 Author Posted April 13, 2017 Hi Ccowgill, It's very close to what I need , but I need the offset lines to be -construction lines, and the line that I pick to be on layer construction line with color red , all this should be only with one command, means when picking the line it will change it to a new layer named construction line in red and the line type will be dashed dot ( axis line). with this code I want to make my work faster. Thank you in advance. Quote
BIGAL Posted April 14, 2017 Posted April 14, 2017 (edited) Its easier to probably start from scratch recoding, if you look at how construction line works it asks for a pick obj point then an offset. So you could pick the centre of a line work out left and right offset pts square off cen pt and just use this point. Need to check object for arcs and circles but same idea. (defun c:2xl ( / obj pt1 pt2 start end off) (setq oldaunits (getvar "aunits")) (setq obj (vlax-ename->vla-object (car (entsel "\nPick object")))) (setq start (vlax-safearray->list (vlax-variant-value(vla-get-startpoint obj)))) (setq end (vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj)))) (setvar "aunits" 3) (setq pt (polar start (angle start end)(/ (distance start end) 2.0))) (vla-put-layer obj "Centerline") (setvar "clayer" "Construction") (setq off (getdist "Enter offset ")) (setq pt1 (polar pt (+ (angle start end)(/ pi 2.0)) off)) (setq pt2 (polar pt (- (angle start end)(/ pi 2.0)) off)) (command "constructionline" pt pt1 "" "") (command "constructionline" pt pt2 "" "") (setvar "Aunits" oldaunits) ) (c:2x1) Edited April 14, 2017 by BIGAL Quote
Recommended Posts
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.