Jump to content

Polyline with offset


cadmikee

Recommended Posts

Here's a version that requires only 3 points, the front two corners of the desk and any point along the back edge of the desk.

u12 is a unit vector from p1 to p2

u43 is a unit vector from the projection of p3 onto line p1 p2 to p3.

 

(defun c:mike2 (/ p1 p2 p3 p4 p5 p6 d e f h osm u12 u43)
; lrm  6/4/2019  
  (setq	p1  (getpoint "\nFront desk corner: ")
	p2  (getpoint "\nOther front desk corner: ")
	p3  (getpoint "\nA beck desk corner: ")
	osm (getvar "osmode")
  )
  (setvar "osmode" 0)
  (setq	d   (distance p1 p2)
	u12 (mapcar '/ (mapcar '- p2 p1) (list d d d))
	e   (dot (mapcar '- p3 p1) u12)
	p4  (mapcar '+ p1 (mapcar '* (list e e e) u12))
	f   (distance p3 p4)
	u43 (mapcar '/ (mapcar '- p3 p4) (list f f f))
	h   (+ f 800.0)
	p5  (mapcar '+ p2 (mapcar '* u43 (list h h h)))
	p6  (mapcar '+ p1 (mapcar '* u43 (list h h h)))
  )
  (command "_.pline" "_non" p1 "_non" p2 "_non"	p5 "_non" p6 "c")
  (setvar "osmode" osm)
  (princ)
)
(defun cross (a b / crs)
  (setq	crs (list
	      (- (* (nth 1 a) (nth 2 b))
		 (* (nth 1 b) (nth 2 a))
	      )
	      (- (* (nth 0 b) (nth 2 a))
		 (* (nth 0 a) (nth 2 b))
	      )
	      (- (* (nth 0 a) (nth 1 b))
		 (* (nth 0 b) (nth 1 a))
	      )
	    )				;end list
  )					;end setq crs
)					;end cross

;;; dot product of 2 vectors a and b
(defun dot (a b / dd)
  (setq dd (mapcar '* a b))
  (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd)))
)

 

Link to comment
Share on other sites

Nice Lrm that's what I was thinking off the unit vector, as the request is to include random objects so just need the square off point.

 

A maybe rather than hard code + 800 a getreal with default of 800. That way will work with other offsets.

 

image.png.c60b3c1c1ae2b87fe764549b3da3d5bc.png

 

(setvar "osmode" 0)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq off (atof (nth 0  (AH:getvalsm (list "Offset plines " "Offset distance" 5 4 "800")))))
(setq	d   (distance p1 p2)
......
......
h   (+ f off)

 

Multi GETVALS.lsp

Link to comment
Share on other sites

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