这些连接到机柜01和02中的模块。
地址为1000的第一个模块(主模块)只有6个输入,输入/输出模块有12个。
因此,当第一个已满时,输入/输出模块1100继续工作。如果是满的,则继续增加1200。。。。1300 .... 等
通常限制为3个输入/输出模块,但有时为7个(输入/输出1800)。
这幅画只是一个例子。在现实生活中,使用了几种类型的组件。
我希望你能从我的意图中有所了解。
测验图纸 在开始研究将要发生的事情时,我认为提供的代码与我们中的一些人可能已经接近的方向不一致,因此提供了回应。
在我看来,更多的是关于控制程序的规则,你有第一次接触,
1x6 1000(满时)
1100的5x12到1500秒(满时)
第二控制器
还是1x6
然后5x12
第三名,以此类推
而不是列表答案。
拼写错误?你把代码放在变量声明中了?
在我看来,如果你能写这段代码,你应该能够修改它以满足你的需要,似乎仍然无法解决它?
如前所述
(lim#x p);参数x应为整数或数字
但是如果您的(色调:StringCal num+i)返回一个字符串
然后,您只需要一些简单的转换atoi&itoa或rtos
假设您的增量限制为“1212”,接下来是“1301”,对吗?
例子:
;oflist ((1001 1 5)(1201 1 12)(1300 2 4))
(setq y 0)
(repeat (length oflist)
(setq stnum (nth 0 (nth y oflist))
(setq inc (nth 1 (nth y oflist))
(setq howmany (nth 2 (nth y oflist))
(repeat howmany
do your attinc now
.....
......
) ; repeat howmany
(setq y (+ y 1))
) ; repeat
;示例:按色调递增后假设:StringCal函数
;==================================================
(defun c:INCATT
( / f str i f tag num pre post OOv
; *StartStr121007
; *IncreaseN121007
;--------------- list PmxCAD --------------------------------------------------------------------------------------------------------------
(setq lst '(1001 1002 1003 1004 1005 1006
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712
1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812
);lst
);setq this one?
;(setq lst '((1001 1 6)(1201 1 12)(1301 1 12)(1401 1 12)(1501 1 12)(1601 1 12)(1701 1 12)(1801 1 12)); or this one?
)
;-----------------------------------------------------------------------------------------------------------------------------
HUE:DivideNum
HUE:memoVar
HUE:stringsubst
HUE:StringCal
HUE:start
HUE:end
_divideStr
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:DivideNum ( str / lst s m v1 v2 i j c _NumP _Cal)
(defun _NumP ( x ) (<= 48 x 57))
(defun _Cal ( ty v )
(set v (cons (vl-list->string (reverse (eval ty))) (eval v)))
(set ty nil)
)
(setq lst (vl-string->list str) i -1 j -1)
(repeat (length lst)
(setq c (nth (setq i (+ i 1)) lst))
(cond
( (_NumP c)
(setq s (cons c s) ) (cond ( m (_Cal 'm 'v1) (setq j (+ 1 j)))))
( (and (= c 46) (> i 0) (_NumP (nth (- i 1) lst)) (_NumP (nth (+ i 1) lst)))
(setq s (cons c s))
)
(t(setq m (cons c m))
(cond ( s (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2))))
)
)
)
(cond
( m (_Cal 'm 'v1))
( t (_Cal 's 'v1) (setq v2 (cons (setq j (+ 1 j)) v2)))
) (list (reverse v1) (reverse v2))
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:memoVar ( va f m s / v )
(setq v (if (member (eval va) '(nil "")) s(eval va)))
(mapcar 'princ (list "\n" m " <" v "> : "))
(set va ( f ))
(if (member(eval va) '(nil "")) (set va v)) (eval va)
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:stringsubst ( new old str / l i ) (setq l (strlen new) i 0)
(while (setq i (vl-string-search old str i))
(setq str (vl-string-subst new old str i) i (+ i l))
) str
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:StringCal ( str f n / _GetPP data1 data2 num i DIMZIN )
(defun _GetPP ( str / lst l post pre flag )
(setq lst(vl-remove45 (vl-string->list str))
post (if (setq l (member 46 lst)) (- (length l) 1) 0)
pre(if (setq l (member 46 (reverse lst))) (- (length l) 1) (length lst))
flag (minusp (atof str))
) (list pre post flag)
)
(setq DIMZIN (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(setq data1 (_GetPP str)
num (vl-string->list (rtos (f (atof str) n) 2 (cadr data1)))
data2 (_GetPP (vl-list->string num))
num (vl-remove 45 num)
)
(setvar 'DIMZIN DIMZIN)
(if (< 0 (setq i (- (cardata1) (cardata2))))
(repeat i (setq num (cons 48 num)))
)
(if (< 0 (setq i (- (cadr data1) (cadr data2))))
(repeat i (setq num (append num '(48))))
)
(if (caddr data2) (setq num (cons 45 num)))
(vl-list->string num)
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:start( lst )
(vla-startundomark (HUE:end nil))
(list lst (mapcar 'getvar lst))
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun HUE:end ( d / doc )
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(and (cadr d) (mapcar 'setvar (car d) (cadr d)))
(if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark doc)) doc
)
;-------------------------------------------------------------------------
; Sub Function
;-------------------------------------------------------------------------
(defun _divideStr ( str / data i j k pre post )
(setq data (HUE:DivideNum str)
k (last (cadr data))
j 0
pre""
post ""
)
(foreach s (car data)
(cond
( (< j k) (setq pre (strcat pres)))
( (> j k) (setq post(strcat post s)))
( (= j k) (setq i s))
)
(setq j (+ 1 j))
)
(list pre i post)
)
;-------------------------------------------------------------------------
; Error Function
;-------------------------------------------------------------------------
(defun *error* (s)
(if OOv (HUE:End OOv)) (princ s)
)
;-----------------------------------------------------------------------------------
; Main Function
;-----------------------------------------------------------------------------------
;(setq str(HUE:MemoVar '*StartStr121007getstring "StartString" "100");-----------------------------------------
;--------------- Example code BIGAL----------------------------------------------------------------------------------------
;oflist ((1001 1 5)(1201 1 12)(1300 2 4))
(setq y 0)
(repeat (length oflist)
(setq stnum (nth y (nth 0 oflist))
(setq inc (nth y (nth 1 oflist))
(setq howmany (nth y (nth 2 oflist))
(repeat howmany
do your attinc now
.....
......
) ; repeat howmany
(setq y (+ y 1))
) ; repeat
;-----------------------------------------------------------------------------------------------------------------------------
i 1
OOv(HUE:Start '(DIMZIN))
)
(and
(vl-string-search "," str)
(setq str (HUE:StringSubst "." "," str)f t)
)
(mapcar 'set '(pre num post) (_DivideStr str))
(setq tag"TEXT1"
num(HUE:StringCal num - i)
)
(setvar 'ERRNO 0)
(setvar 'DIMZIN
(while (= 0 (getvar 'ERRNO))
(and
(setq o (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1))))
;(C:PUTA);------------------------------------------------------put locationcode-----------------------------------
(vl-some
'(lambda ( att )
(if (= tag (vla-get-tagstring att))
(progn
(setq num (HUE:StringCal num + i)
str (strcat pre num post)
)
(if f (setq str (HUE:StringSubst "," "." str)))
(vla-put-textstring att str)
)
)
) (vlax-invoke (vlax-ename->vla-object (ssname o 0)) 'getattributes)
)
)
)
(HUE:End OOv)
(princ)
)(vl-load-com)
Starting to work out what is meant to happen I think the code provided is not in the same direction as say some of us would have approached hence the responses provided.
It seems to me to be more about the rules controlling the procedure, you have the first contact,
1x6 1000's when full
1100's 5x12 up to 1500,s when full
2nd controller
again 1x6
then 5x12
3rd and so on
Rather than a list answer.
typos? you put the code in variable declaration?
IMO if you could write this code, you should be able to modify it to suit your needs seems still can't solve it?
as mentioned
(lim# x p) ;argument x, should be integer or a number
but if your (HUE:StringCal num + i) returns a string
then you just need some simple conversion atoi & itoa or rtos
assume your increment limits "1212", next will be "1301" right?
example:
(setq num "1212")(setq num (HUE:StringCal num + i) ;output num as string x (lim# (atoi num) NIL) ; convert num to integer num (itoa x) ;convert back to string str (strcat pre num post) ; returns as string concatenate )
;example : assume after increment by HUE:StringCal function
(setq num "1213")(setq x (lim# (atoi num) nil)) ; apply my function (setq num (itoa x)) ; "1301" new value as string
页:
1
[2]