;;; ENDTICK.LSP
;;;
;;; Copyright 2006 Thomas Gail Haws
;;; This program is free software under the terms of the
;;; GNU (GNU--acronym for Gnu's Not Unix--sounds like canoe)
;;; General Public License as published by the Free Software Foundation,
;;; version 2 of the License.
;;;
;;; You can redistribute this software for any fee or no fee and/or
;;; modify it in any way, but it and ANY MODIFICATIONS OR DERIVATIONS
;;; continue to be governed by the license, which protects the perpetual
;;; availability of the software for free distribution and modification.
;;;
;;; You CAN'T put this code into any proprietary package. Read the license.
;;;
;;; If you improve this software, please make a revision submittal to the
;;; copyright owner at www.hawsedc.com.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License on the World Wide Web for more details.
;;;
;;; DESCRIPTION
;;;
;;; ENDTICK inserts and aligns the ENDTICK block at the endpoint of every arc or line
;;; in a selection set. It removes duplicate ticks.
;;;
;;; ENDTICK is useful for surveying and civil engineering plans to demarcate points of
;;; curvature, tangency, et cetera.
;;;
;;; You can make your own ENDTICK block if you prefer some custom shape or size tick.
;;; The default ENDTICK block is a one unit long vertical line with its insertion point
;;; at its midpoint. ENDTICK scales the ticks to the dimension text height
;;; (dimscale * dimtext), so the default ENDTICK block will look as big as the current
;;; dimension text height.
;;;
;;; Revisions
;;; 20060914 TGH Version 1.0PR released. 3 hrs. Works only with world UCS and View
;;; Modified by Irn?Barnard on 2010-01-15 to allow for polylines as well, noted with comments starting with IB:
(setq EndTick:BlkName
"endtick") ;IB: Change this if block's name is different
(defun c:ENDTICK
() (ENDTICK
))
(defun ENDTICK
;;No global variables. All the variables should be listed here as local. (/ CENPOINT DS DT ENDANG ENDPOINT ENTLIST ENTNAME
ENTTYPE I MINTICKSEPARATION RADIUS SS1 STARTANG STARTPOINT
TICKLIST TS ENTOBJ ;IB: Added ENTOBJ for ActiveX object reference
)
;;Set initial variables
ts (* ds dt)
;;If endpoints are closer together than the distance given below
;; and also aligned angularly closer than the angular difference below,
;; ENDTICK only plots the first one of them it finds.
mintickseparation (* ts 0.01)
;;In radians. Setting to some big number like 10 (larger than 2 pi) will remove coincident ticks even with different rotations.
mintickangulardif 0.01
) ;_ end of setq
;;Get selection set from user. Limit to lines and arcs.
(setq ss1
(ssget '
((0 .
"LINE,ARC,LWPOLYLINE,POLYLINE"))) ;IB: Added LWPOLYLINE and POLYLINE i -1
) ;_ end of setq
;;Get endpoints and orientations from selection set
) ;_ end of setq
((= enttype "LINE")
ticklist (ENDTICK-addtolist
(list startpoint
(angle startpoint endpoint
)) ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
ticklist (ENDTICK-addtolist
endpoint
(angle endpoint startpoint
) ) ;_ end of list
ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
) ;_ end of setq
)
((= enttype "ARC")
startpoint
(polar cenpoint startang radius
) endpoint
(polar cenpoint endang radius
) ticklist (ENDTICK-addtolist
(list startpoint
(+ startang
(/ pi
2))) ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
ticklist (ENDTICK-addtolist
(list endpoint
(+ endang
(/ pi
2))) ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
) ;_ end of setq
)
;; IB: Section added to do Polyline's
((wcmatch enttype
"LWPOLYLINE,POLYLINE") ENTOBJ
(vlax
-ename
->vla-object entname
) ;Get the ActiveX object reference from the ename startang
(angle '
(0.0 0.0 0.0) ;Get the start angle ) ;_ end of angle
endang
(angle '
(0.0 0.0 0.0) ;Get the end angle ) ;_ end of angle
ticklist (ENDTICK-addtolist
(list startpoint
(+ startang
(/ pi
2))) ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
ticklist (ENDTICK-addtolist
(list endpoint
(+ endang
(/ pi
2))) ticklist
mintickseparation
mintickangulardif
) ;_ end of ENDTICK-addtolist
) ;_ end of setq
) ;IB: End of section added
) ;_ end of cond
) ;_ end of while
;; IB: Modified to suit both uniform and non-uniform scaled blocks
EndTick:BlkName
) ;_ end of vla-Item
) ;_ end of setq
) ;_ end of and
(if (= (vla
-get
-BlockScaling DS
) 0) ;; If non Uniform scaling
) ;_ end of foreach
;; Else with uniform scaling
) ;_ end of foreach
) ;_ end of if
"Please note, block ["
EndTick:BlkName
"] is not available in this drawing. Change the name used in the LSP file or insert the block to this drawing."
) ;_ end of strcat
) ;_ end of princ
) ;_ end of if
) ;_ end of defun
;; IB: Added function to convert Radians to Degrees
(defun Rad2Deg
(Rad
/) (* 180.0 (/ Rad pi
)))
(defun ENDTICK
-addtolist
(tick ticklist mintickseparation mintickangulardif
/ dupfound templist tickcheck
) ;;Look for duplicates in list
(< (abs (- (cadr tick
) (cadr tickcheck
))) mintickangulardif
) ) ;_ end of and
dupfound
T
templist
nil
) ;_ end of setq
) ;_ end of if
) ;_ end of while
ticklist
) ;_ end of if
) ;_ end of defun
;|玍isual LISP?Format Options?
(120 2 1 2 T "end of " 90 9 0 0 0 nil T nil T)
;*** DO NOT add text below the comment! ***|;