Bazılarına (mesela K.A’ya) çizgileri “divide” ile eşit parçalarda nokta koymak yetmedi, çizgileri parçalayalım dedi :) bunun için autocadde bir komut yok, ancak sevdiğimiz canımız lispler var. Bu lispi Kent Cooper yazmış; seçtiğiniz çigiyi istediğiniz sayıda eşit parçalara pinçikliyor... lazımsa aşağıdan kodu kopyalayın, her zamanki gibi; “Notepad’e yapıştır--> kaydet--> uzantısını .lsp olarak değiştir--> autocadi aç--> appload komutunu çalıştır--> bu lispi seç--> yükle” SD komutu ile çalıştırabilirsiniz.
;; SubDivide.lsp [command name: SD]
;; To SubDivide a finite linear object into a specified
;; number of equal-length contiguous sections.
;; Works on anything of finite length that Break can
;; be used on [not Xlines or Rays].
;; Kent Cooper, October 2009
;
(defun C:SD (/ *error* subdiv obj cmde blips osm esel ent etype entlen secs seclen ent2 secs1 secs2)
;
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort"))
(princ (strcat "\nError: " errmsg))
); end if
(setvar 'osmode osm)
(setvar 'blipmode blips)
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
); end defun *error*
;
(defun subdiv (obj brks)
(repeat brks
(command
"_.break"
obj
(trans (vlax-curve-getPointAtDist obj seclen) 0 1)
"@"
); end command
(setq obj (entlast))
); end repeat
); end defun - subdiv
;
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(command "_.undo" "_begin")
(setq
blips (getvar 'blipmode)
osm (getvar 'osmode)
); end setq
;
(while
(not
(and
(setq esel (ssget ":S" '((0 . "LINE,ARC,CIRCLE,*POLYLINE,ELLIPSE,SPLINE"))))
(= (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 (entget (ssname esel 0))))))) 0); 0 for Unlocked, 4 for Locked
); end and
); end not
(prompt "\nNothing selected, or object is not a finite path type, or is on a Locked Layer; try again:")
); end while
(setvar 'osmode 0)
(setvar 'blipmode 0)
(initget 7)
(setq
ent (ssname esel 0)
etype (if ent (cdr (assoc 0 (entget ent))))
entlen (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
secs (getint "\nNumber of Sections to SubDivide into: ")
seclen (/ entlen secs)
); end setq
; (command "_.divide" ent secs) ; remove leading ; if Points are desired along with subdivision
(cond
( ; Circle or closed Ellipse/Spline [can't break at one point]
(or
(= etype "CIRCLE")
(and (wcmatch etype "ELLIPSE,SPLINE") (vlax-curve-isClosed ent))
); end or
(command "_.copy" ent "" "0,0" "0,0"); make a copy in place
(setq
ent2 (entlast)
secs1 (/ secs 2)
secs2 (- secs secs1)
); end setq
(command
"_.break"
ent
(trans (vlax-curve-getStartPoint ent) 0 1)
(trans (vlax-curve-getPointAtDist ent (* seclen secs1)) 0 1)
"_.break"
ent2
(trans (vlax-curve-getPointAtDist ent2 (* seclen secs1)) 0 1)
(trans (vlax-curve-getStartPoint ent2) 0 1)
); end command
(subdiv ent (1- secs2))
(subdiv ent2 (1- secs1))
); end Circle or closed Ellipse/Spline condition
(T ; everything else
(subdiv ent (1- secs))
); end everything-else condition
); end cond
;
(setvar 'osmode osm)
(setvar 'blipmode blips)
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ)
); end defun
(prompt "Type SD to SubDivide a linear object.")