Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted (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 by BIGAL

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...