Author Topic: Offset Point  (Read 1272 times)

0 Members and 1 Guest are viewing this topic.

ScottMC

  • Newt
  • Posts: 193
Offset Point
« on: August 31, 2021, 10:42:46 AM »
Offsets from object start-point distance by pick or entry. If there's any suggestions.. Thanks for input! Source page: dubb.. https://www.theswamp.org/index.php?topic=52715.msg576003#msg576003
Agree BIGAL..

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ko (/ newlen plotpt pt offset ang side)
  2.   (princ "\n Insert Point using Offset.")
  3.     (ssget "_X" '((0 . "ARC,LINE,*POLYLINE")))
  4.      (while (and (not (setq ent (car (entsel "\n >> Select *Line/Arc to Offset FROM >>")))))
  5.     (/= (getvar "ERRNO") 52))
  6.  
  7.   (setq newlen 0
  8.         offset 0
  9.   ) ;_ end of setq
  10.   (setq plotpt
  11.          (getdist "\nEnter/Pick Distance from Start of Reference: ")
  12.   ) ;_ end of setq
  13.   (setq
  14.     offset  
  15.            (getdist "\n Enter/Pick Offset Distance: ")
  16.   ) ;_ end of setq
  17.   (setq newlen (+ plotpt newlen))
  18.   (setq pt (vlax-curve-getpointatdist ent newlen))
  19.   (setq ang (angle '(0.0 0.0)
  20.                    (trans (vlax-curve-getfirstderiv
  21.                             ent
  22.                             (vlax-curve-getparamatpoint ent pt)
  23.                           ) ;_ end of vlax-curve-getfirstderiv
  24.                           0
  25.                           ent
  26.                           t
  27.                    ) ;_ end of trans
  28.             ) ;_ end of angle
  29.   ) ;_ end of setq
  30. (initget "A B I O L R")
  31.   (setq side
  32.          (getkword
  33.            "\n Enter Side Above/Inside/Left or Below/Outside/Right [A/I/L/B/O/R]: <On> "
  34.          ) ;_ end of getkword
  35.   ) ;_ end of setq
  36.   (cond
  37.     ((or
  38.        (= side "A")
  39.        (= side "I")
  40.        (= side "R")
  41.      ) ;_ end of or
  42.      (setq ang (+ ang (/ pi 2.0)))
  43.     )
  44.     ((or
  45.        (= side "B")
  46.        (= side "O")
  47.        (= side "L")
  48.      ) ;_ end of or
  49.      (setq ang (- ang (/ pi 2.0)))
  50.     )
  51.   ) ;_ end of cond
  52.  
  53.   (setq obj (vlax-ename->vla-object ent))
  54.   (setq pt (polar pt ang offset))
  55.               (cons 0 "POINT")
  56.               (cons 10 pt)
  57.               (cons 8 "non-print")
  58.             ) ;_ end of list
  59.   ) ;_ end of entmakex
  60.   ;;(princ "\Point Added")
  61.   (princ)
  62. ) ;_ end of defun
  63.  




EDIT (John): Added code tags.
« Last Edit: September 03, 2021, 08:50:02 AM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1414
  • 40 + years of using Autocad
Re: Offset Point
« Reply #1 on: September 02, 2021, 08:52:24 PM »
1.5707963267948966192313216916395

(setq ang (+ ang (/ pi 2.0)))

or if lots of std angs

(setq pi90 (/ pi 2.0) pi45 (* pi 0.25)  pi135 (* 0.75 pi) and so on.
A man who never made a mistake never made anything