Create new lines to predetermined layer

A routine I do many times is to offset (parallel) lines/ polylines a set distance (1/2 the current text size) from their parent entities and change these new lines/ polylines to a set layer.
I use those as guide (lines) to position text and other objects a set distance from the linework.

This can get tedious.

Is there a routine that does this please?

Comments

  • I use something similar

    (Defun C:OLAY (/ od la a s1)
    (print oldist)
    (setq od (getdist "\nOffset Distance: "))
    (if (= nil od)(setq od oldist)(setq oldist od))
    (print lanam)
    (setq la (getstring "\nNew Layer: "))
    (if (not lanam)(setq lanam (getvar "clayer")))
    (if (equal "" la)(setq la lanam)(setq lanam la))
    (while od
    (setq a (entsel "\nPick Entity to Offset \n"))
    (setq s1 (getpoint "\nSide to Offset "))
    (command "offset" od a s1 "")
    (entmod (subst (cons 8 la)(assoc 8 (entget (entlast)))(entget (entlast))))
    ))

     If you (setq od (/ (getvar "textsize") 2)) to automatically enter the distance, and likewise (setq la "yourlayer") if it's a constant, it should work without asking any questions. I haven't tried it as below, it might not be exactly as you want it.

    (Defun C:OLAY ()
    (setq od (  (/ (getvar "textsize") 2))

    (setq la "yourlayer")
    (while od
    (setq a (entsel "\nPick Entity to Offset \n"))
    (setq s1 (getpoint "\nSide to Offset "))
    (command "offset" od a s1 "")
    (entmod (subst (cons 8 la)(assoc 8 (entget (entlast)))(entget (entlast))))
    ))

  • Thanks John
    Got the first to work but not second.  Will play about with that as its probably at my end.
    LISP isn't familiar with me so probably explains some things.
    regards
    Richard
  • It's hard to play around with someone else's program, but this sort of routine is a handy use of lisp for not too much effort.

    I use text style heights of 0 and set the height for each text or mtext, usually one main style. There is usually one main text height in a file so I set the size once and don't have to change it often.

    That causes differences in how lisps behave when they find out the current text height.

    Also, sorry I made a mistake-

    (setq od ( (/ (getvar "textsize") 2))

    should be

    (setq od (/ (getvar "textsize") 2))

    Correct number of left and right braces is important in lisp.

  • Thanks again John
    yes that works well now.
    One very happy (nonpaying) customer.

    I'll look at your other suggestions.  Any improvements at this end are good.
    regards
    Richard
  • This is a huge boost to output.  Great stuff.
    Is it possible to have it parallel offset both sides without asking please?
    I imagine Yes, but!! This 'ol bloke is stuck on the howto.

    John your comment re text height, text style height etc have proved themselves for my use and it's good to just hit Enter and keep going.

    regards
    Richard
  • (Defun C:OLAY1 () 
    (setq od ( (/ (getvar "textsize") 2))
    (setq la "yourlayer") 
    (while od
    (setq a (entsel "\nPick Entity to Offset \n"))
     (command "offset" od a "B" "") 
    (entmod (subst (cons 8 la)(assoc 8 (entget (entlast)))(entget (entlast))))

    ))


    Without trying it, that should work.

  • Thanks John
    Couldn't get that to work, but I then cobbled together some of your offerings and got this.

    (Defun C:OLAY3 ()
    (setq od (getdist "\nOffset Distance: "))
    (setq la (getstring "\nNew Layer: "))
    (while od
    (setq a (entsel "\nPick Entity to Offset \n"))
     (command "offset" od a "B" "")
    (entmod (subst (cons 8 la)(assoc 8 (entget (entlast)))(entget (entlast))))
    ))

    And it worked - in Model and Paper Space too. (I thought Tassie was the place for eccentrics !!?)
    Seriously - Much appreciated
    Richard

  • Now it's back to asking you for the distance. One reason I see now why it wouldn't work properly is because I cut and paste the original mistake at (setq od ((...

    Trust no one.

    Waddya mean eccentric? - the self-important states heap enough dirt on us 'yokels' without doing it among ourselves.

    Fortunately I take eccentric as a compliment. I would suggest though, that when anyone disappears from 'Neighbours' it's always WA though choose to go to.

  • @ Richard:
    Your code has an endless loop and only changes 1 new entity to the desired layer. Try the attached file Olay4.lsp.



    Olay4.lsp

  • Yes thats right Roy.  I found that after I posted.
    'Endless Loop'!! Sounds like the sort of thing I'd do.
    Was intending to fix and get back.  You beat me too it.
    So many thanks for the updated, corrected version.

    John my remark was in relation to another post and your comment re some ancient requirement for dwg's given to a local authority.  Didn't mean it at you, not sure if you took it that way.  I don't think so.  So apologies for any disturbance there.
    I was really having a hit at us here.  The way Tasmanians get viewed sometimes and unjustly so. (LOL)

    regards
    Richard
  • No offense taken. Eccentric ain't the word for that govt department, too nice for the govt as well btw.

    The loop suits my purposes, I go around picking one entity at a time and escape when finished.

    When I make up a lisp it's often to do a repetitive job and I don't spend much time polishing them up.

    My lisp knowledge is fairly shallow, but still it's extremely useful.

This discussion has been closed.