@john.uhden wrote:
Mr. Haider,
Why not just use the OFFSET command?
I use FIELD to generate area tags and offset would create a totally new polyline which I need to reconnect to each FIELD text..
@ВeekeeCZ wrote:
Yes, Shift+RMT P to launch a perpendicular osnap mode as a temporary override.
Love this feature. I even customized the key letters to be easier to remember to me.
Contrarily the built-in Temp Override Shortcuts or keys I consider unreliable.
Indeed a good feature. Would you please share how you customized the key letters?
And regarding the Temp Override Shortcuts, what do you dislike there? I can see there are shortcuts defined, but I could never figure out how to use them
@Sea-Haven wrote:
Try this hopefully self explaining.
; move a pline segment based on a x or y point
; By AlanH march 2021
(defun c:plseg( / plent pick plobj pick2 param segment co-ord pt1 pt2 pt3 xy1 xy2 x y new_coord1 oldsnap)
(setq plent (entsel "\nSelect Pline segment "))
(setq
pick (cadr plent)
plObj (vlax-ename->vla-object (car plent))
pick2 (vlax-curve-getclosestpointto plobj pick)
param (vlax-curve-getparamatpoint plObj pick2)
segment (fix param)
co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))
)
(setq pt1 (nth segment co-ord))
(setq pt2 (nth (+ segment 1) co-ord))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 1)
(setq pt3 (getpoint "\nPick point for reference "))
(setvar 'osmode 0)
(setq x (car pt3) y (cadr pt3))
(setq xy (getstring "\nDo you want X or Y "))
(if (= (strcase xy) "X")
(setq xy1 (list x (cadr pt1)) xy2 (list x (cadr pt2)))
)
(if (= (strcase xy) "Y")
(setq xy1 (list (car pt1) y) xy2 (list (car pt2) y))
)
(setq pt1 (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 1)) xy1)))
(vla-put-coordinate plobj segment pt1)
(setq pt2 (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 1)) xy2)))
(vla-put-coordinate plobj (+ segment 1) pt2)
(setvar 'osmode oldsnap)
(princ)
)
Great solution @Sea-Haven
Two questions:
1) On some polylines, this lisp halts. I get this
Do you want X or Y y
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
What do you think the causes could be?
2) You think you can make the LISP understand the X or Y based on the picked reference line?
Right now, your script works on perpendicular angles in either X or Y. This means if the reference line's two verts are located in 0,0 and 10,0 then we could calculate that the alignment should be X.
While if the verts would be 0,0 and 0,10 then we have Y alignment.
From the examples above, if both X values are the same then we have Y alignment and if both Y values are similar we have X alignment, right?
You could even put in a threshold value, so that if you have 0,0 and 0.1,10 it would still be considered as X. Or maybe not, then the user would know that the reference line isn't 100% perpendicular and need to act on it.