Why have error ?
>Select the curve
..>>Select the arrangement of objects along:
...>>>The length of the curve15.821,Enter the spacing: 5
....>>>>The spacing of first object & Curve endpoint<0.410>:
._copy
Select objects: 1 found
Select objects:
Specify base point or [Displacement/Multiple] <Displacement>: non Specify
second point or <use first point as displacement>: non
Command: _.rotate
Current positive angle in UCS: ANGDIR=counterclockwise ANGBASE=0
Select objects: 1 found
Select objects:
Specify base point: non
Specify rotation angle or [Copy/Reference] <0>:
Backtrace:
[0.48] (VL-BT)
[1.44] (*ERROR* "bad argument type: numberp: nil")
[2.39] (_call-err-hook #<SUBR @0e81e8c0 *ERROR*> "bad argument type: numberp:
nil")
[3.33] (sys-error "bad argument type: numberp: nil")
:ERROR-BREAK.28 nil
[4.25] (- 0.938951 nil)
[5.19] (C:SM)
[6.15] (#<SUBR @0e81e9d8 -rts_top->)
[7.12] (#<SUBR @0dcc435c veval-str-body> "(C:SM)" T #<FILE internal>)
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:ARQ-SUBR-CALLBACK.3 (nil 0)
Command:
Error!
This is the source code:
(defun C:SM (/ A AN AN0 BASEPT BETWEEN BOOL CURVEBLOCK CURVELENGTH DISTANC EN FIRSTPOINT LASTB LASTBLIST LASTBLOCK N PP PT PT0 SSADD1 STRIN TRIN VT)
(defun *error* (msg)
(vl-bt)
(if *DOC*
(_EndUndo *DOC*)
)
(while (not (equal (getvar "cmdnames") "")) (command nil))
(princ "\n Error!")
(princ)
)
(defun stratpointT (en pt0 / CURVELENGTH L1)
(setq CurveLength
(vlax-curve-getDistAtParam
en
(vlax-curve-getEndParam en)
)
)
(setq L1 (vlax-curve-getDistAtPoint en pt0))
(< L1 (- CurveLength L1))
)
(defun NAME_BLK (CurveLength / A Y)
(setq A (rtos (* (getvar "CDATE") 1E8)))
(setq Y (/ CurveLength 5.0))
(entmake (list '(0 . "LINE")
(cons 10 (list 0 0 0))
(cons 11 (list 0 y 0))
)
)
(command "_.BLOCK"
A
"non"
(list 0 (/ y 2.0) 0)
(entlast)
""
)
A
)
(defun MyAttAdd (en n / ELIST N1 N3 NEND QIANZ STREND TEXT)
(setq elist (entget (entnext en)))
(setq text (cdr (assoc 1 elist)))
(setq n3 (strlen text))
(setq strEND (getNumberS text))
(setq Nend (nth (1- (length strEND)) strEND))
(setq n1 (strlen Nend))
(setq qianZ (substr text 1 (- n3 n1)))
(setq strEND (+ (atof (car strEND)) n))
(setq strEND (strcat qianZ (rtos strEND 2 3)))
(entmod (subst (cons 1 strEND) (assoc 1 elist) elist))
(entupd en)
)
(defun MyTextAdd (en n / ELIST N1 N3 NEND QIANZ STREND TEXT)
(setq elist (entget en))
(setq text (cdr (assoc 1 elist)))
(setq n3 (strlen text))
(setq strEND (getNumberS text))
(setq Nend (nth (1- (length strEND)) strEND))
(setq n1 (strlen Nend))
(setq qianZ (substr text 1 (- n3 n1)))
(setq strEND (+ (atof (car strEND)) n))
(setq strEND (strcat qianZ (rtos strEND 2 3)))
(entmod (subst (cons 1 strEND) (assoc 1 elist) elist))
)
(vl-load-com)
(or *DOC*
(setq *DOC* (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(_StartUndo *DOC*)
(setvar "nomutt" 1)
(princ "\n >Select the curve")
(while (not
(and (setq en (ssget ":E:S" '((0 . "*LINE,ARC,ELLIPSE"))))
(setq en (ssname en 0))
)
)
(princ "\n >Re select the curve")
)
(setvar "nomutt" 0)
(setq pt0 (vlax-curve-getClosestPointTo en (cadr (grread T 8))))
(setq CurveLength
(vlax-curve-getDistAtParam
en
(vlax-curve-getEndParam en)
)
)
(setq curveBlock
(car (ENTSEL "\n ..>>Select the arrangement of objects along:"))
)
(if curveBlock
nil
(progn (setq A (NAME_BLK CurveLength))
(command "_.INSERT" A "@" "" "" "")
(setq lastblock (entlast))
(setq curveBlock lastblock)
)
)
(setq an0 (entget curveBlock))
(setq basePt (cdr (assoc 10 an0)))
(setq an0 (cdr (assoc 50 an0)))
(setq bool T)
(setq strin (strcat "\n ...>>>The length of the curve"
(rtos CurveLength 2 3)
",Enter the spacing: "
)
)
(while bool
(initget 7)
(setq between (getreal strin))
(if (> between CurveLength)
(progn (setq bool T) (alert "Object spacing must be smaller than the curve length!!!"))
(setq bool nil)
)
)
(initget 4)
(setq strin (rtos (/ (rem CurveLength between) 2.0) 2 3))
(setq
distanc (getreal
(strcat "\n ....>>>>The spacing of first object & Curve endpoint<" strin ">:")
)
)
(if distanc
nil
(setq distanc (/ (rem CurveLength between) 2.0))
)
(setq n (fix (/ (- CurveLength distanc) between)))
(if (stratpointT en pt0)
(setq firstPoint distanc)
(setq firstPoint (rem (- CurveLength distanc) between))
)
(setq ssadd1 (ssadd))
(repeat (setq n (1+ n))
(setq pt (vlax-curve-getPointAtDist en firstPoint)
pp (vlax-curve-getParamAtPoint en Pt)
vt (vlax-curve-getFirstDeriv en pp)
an (angle '(0 0 0) vt)
)
(command "._copy" curveBlock "" "non" basePt "non" PT)
(setq LastB (entlast))
(setq LastBList (entget LastB))
(cond ((assoc 66 LastBList) (MyAttAdd LastB (setq n (1- n))))
((equal (cdr (assoc 0 LastBList)) "TEXT")
(MyTextAdd LastB (setq n (1- n)))
)
)
;;(entmod (subst (cons 50 an) (assoc 50 LastBList) LastBList))
(command "_.rotate" LastB "" "non" pt (/ (* 180 (- an an0)) pi))
(setq ssadd1 (ssadd LastB ssadd1))
(setq firstPoint (+ firstPoint between))
)
(if lastblock
(command "._erase" lastblock "")
(progn (initget "R ")
(setq trin
(getstring "\nTo block rotated 180 degrees, input R<Enter>")
)
(if (or (equal trin "R") (equal trin "r"))
(repeat (setq n (sslength ssadd1))
(setq LastB (ssname ssadd1 (setq n (1- n))))
(setq LastBList (entget LastB))
(setq an (cdr (assoc 50 LastBList)))
(setq an (+ an pi))
(entmod (subst (cons 50 an) (assoc 50 LastBList) LastBList))
)
)
)
)
(_EndUndo *DOC*)
(princ)
)
(defun _StartUndo (*DOC*)
(_EndUndo *DOC*)
(vla-StartUndoMark *DOC*)
)
(defun _EndUndo (*DOC*)
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndoMark *DOC*)
)
)