;;;----------------------------------------------------------------------- ;;; Makro : C:KM_PWIDTH ;;; Version : v1.0 ;;; Date : 17.12.2006 ;;; Version : AutoCAD 200x ;;; Author : Muharrem Kocyigit (c) 2006 ;;;----------------------------------------------------------------------- ;;; ;;; USAGE: ;;; ;;; You are free to use the information listed here, but it is copyrighted ;;; works and are not public domain. You may not sell, lease, or ;;; mass-redistribute this information on disk or electronically. You may ;;; not post this information online (including web sites, ftp sites, ;;; bulletin boards, and other online services) for public viewing, and ;;; you may not publish in print for public viewing without prior written ;;; consent of Author ! ;;; ;;; DISCLAIMER: ;;; ;;; THE AUTHOR DISCLAIMS ANY AND ALL LIABILITY FOR ANY DAMAGES ARISING OUT ;;; OF THE USE OR OPERATION, OR INABILITY TO USE ANY INFORMATION AVAILABLE ;;; HERE. FURTHERMORE, BY USING THIS INFORMATION YOU AGREE TO HOLD AUTHOR ;;; HARMLESS FROM SUCH CLAIMS. The Author makes no warranty, either ;;; expressed or implied, as to the fitness of this information for any ;;; particular purpose. All materials are to be considered ‘as-is’, and use ;;; of any information should be considered as AT YOUR OWN RISK! ;;; ;;;----------------------------------------------------------------------- (setq glv:polyline:width nil) (setq glv:old:error nil) ;;;----------------------------------------------------------------------- (defun PWidth-Set-Value (obj a_width / n nCoords nLBound nUBound nVertices) (cond ((member (vla-get-ObjectName obj) '("AcDb2dPolyline")) (setq nCoords (vlax-variant-value (vla-get-Coordinates obj)) nLBound (vlax-safearray-get-l-bound nCoords 1) nUBound (vlax-safearray-get-U-bound nCoords 1) ) (setq nVertices (/ (- nUBound nLBound) 2)) (setq nVertices (1+ nVertices)) (setq nVertices (if (= (vla-get-Closed obj) :vlax-true) (+ nVertices 0) (- nVertices 1) ) ) (setq n -1) (while (< n nVertices ) (if (vlax-method-applicable-p obj 'SetWidth ) (if (vlax-write-enabled-p obj) (vl-catch-all-error-p (vl-catch-all-apply 'vla-SetWidth (list obj (setq n (1+ n)) a_width a_width) ) ) ; end catch ) ; end if -2 ) ; end if -1 ) ; end while ) ((member (vla-get-ObjectName obj) '("AcDbPolyline")) (vla-put-ConstantWidth obj a_width) ) ) ; end cond ) ;;;----------------------------------------------------------------------- (defun PWidth-Modify ( ss / n e ssLen obj ) (setq n 0 ssLen (sslength ss) ) (while (< n ssLen) (setq e (ssname ss n)) (setq obj (vlax-ename->vla-object e )) (PWidth-Set-Value obj glv:polyline:width) (setq n (1+ n)) ) ) ;;;----------------------------------------------------------------------- (defun PWidth-Get-Value ( a_msg a_glo a_def / valRet valDef ) (setq valDef (if (null a_glo ) a_def a_glo ) ) (initget 4) (setq valRet (getreal (strcat a_msg " <" (rtos valDef 2 3) ">: "))) (if (null valRet) valDef valRet ) ) ;;------------------------------------------------------------------------ (defun PWidth-Error (s) (if (not (member s '("quit / exit abort" "Function cancelled" "Beenden/Verlassen abbrechen""Funktion abgebrochen"))) (mapcar 'princ (list "\n>>> *ERROR* \"" s "\" \n" )) ) (setq *error* glv:old:error) (setq glv:old:error nil ) ) ;;;----------------------------------------------------------------------- (defun C:KM_PWIDTH ( / ss) (setq glv:old:error *error*) (setq *error* PWidth-Error ) (mapcar 'princ (list "\nMakro: \"KM_PWIDTH\" programed by M. Kocyigit" "\nChange the global width of one or multiple Polylines" "\n" )) (if (setq ss (ssget)) (progn (setq glv:polyline:width (PWidth-Get-Value "Specify new width for POLYLINE" glv:polyline:width 0.0 ) ) (PWidth-Modify ss ) ) ) (setq *error* glv:old:error) (setq glv:old:error nil) (princ) ) ;;;----------------------------------------------------------------------- (princ "\nMakro \"KM_PWIDTH\" loaded ...") (princ) ;;-----------------------------------------------------------------------