ryankevin15 发表于 2022-7-5 16:23:39

需求电流Lisp

你好,有人能帮我打个电话吗。lsp用于计算与这两个LISP类似的需求安培数,用于加法,以及计算相位平衡百分比(%)?
 
它们的工作方式是选择一个值,点击空格键执行命令,然后选择用于计算的目标文本。
 
相位平衡。LSP
 
这lsp将提示输入需求瓦特数,除以360,然后提示用户输入目标文本。我想把安培数四舍五入到最接近的十。
 
提前谢谢你。

BKT 发表于 2022-7-5 16:34:24

试试这个:
 
(defun c:208 (/ watts amps ent)

(while (= watts nil)
   (setq watts (car (entsel "\nSelect Demand Watts: ")))
)

(setq watts (cdr (assoc 1 (entget watts)))
   amps (rtos (/ (atof watts) 360) 2 1)
)

(while (= ent nil)
   (setq ent (car (entsel "\nSelect Target Entity: ")))
)

(setq ent (subst (cons 1 amps) (assoc 1 (entget ent)) (entget ent)))

(entmod ent)

(princ)

)

BKT 发表于 2022-7-5 16:36:45

凉的如果它对你有效,那么用它制作一个480美元的就很容易了。只需更改lisp的名称和“360”条目。

ryankevin15 发表于 2022-7-5 16:44:59

工作完美,制作了一个480V。太感谢你了!

ryankevin15 发表于 2022-7-5 16:49:36

你认为可以让lisp例程有一行代码,在命令行中除以360后显示总数吗?使用“添加”命令后,它会在您将其放入图形之前告诉您总和。

BKT 发表于 2022-7-5 16:55:43

查看添加此代码是否满足您的需要:
 
(defun c:208 (/ watts amps ent)

(while (= watts nil)
   (setq watts (car (entsel "\nSelect Demand Watts: ")))
)

(setq watts (cdr (assoc 1 (entget watts)))
   amps (rtos (/ (atof watts) 360) 2 1)
)

(princ (strcat "\nTOTAL DEMAND AMPS = " amps))

(while (= ent nil)
   (setq ent (car (entsel "\nSelect Target Entity: ")))
)

(setq ent (subst (cons 1 amps) (assoc 1 (entget ent)) (entget ent)))

(entmod ent)

(princ)

)

ryankevin15 发表于 2022-7-5 16:58:32

令人惊叹的此外,如果用户意外错过了文本或选择了一行,则在用户选择数字之前,添加命令似乎不会执行或退出。这是否可能用于208和480v?

BKT 发表于 2022-7-5 17:05:11

现在,代码需要选择一些内容,但不排除文本以外的实体。让我来处理一下,我会给你回电话的。
 
此外,我制作了一个新版本,允许您在加载程序后输入“208”或“480”,因此如果您想在流程中保存几个步骤,可以使用该步骤。

ryankevin15 发表于 2022-7-5 17:12:48

谢谢你的帮助!

BKT 发表于 2022-7-5 17:14:09

我结合了一些代码,为您提供了一些其他的尝试:
 
(defun c:test (/ ss i n text1 total volts amps)

(initget 1 "208 480")
(setq volts (getkword "\nEnter Voltage < 208 / 480 > : "))

(if (= volts "208")
   (setq volts 360)
   (setq volts 831)
)

(setq ss (ssget '((0 . "TEXT")))
   i 0
   total 0
   n (sslength ss)
)

(if ss
   (while (< i n)
   (setq text1 (cdr (assoc 1 (entget (ssname ss i)))))
   (setq total (+ total (atof text1)))
   (setq i (1+ i))
   )
)

(princ (strcat "\nTOTAL WATTS = " (rtos total 2 0)))

(while (not (setq watts (car (entsel "\nUpdate TOTAL DEMAND WATTS: ")))))
(setq watts (entget watts))
(if (eq (cdr (assoc 0 watts)) "TEXT")
   (entmod (setq watts (subst (cons 1 (rtos total 2 0)) (assoc 1 watts) watts)))
   (progn
       (princ "\nWrong Selection - Not Text!!")
       (exit)
   )
)

(princ (strcat "\nTOTAL AMPS = " (rtos (/ total volts) 2 1)))

(while (not (setq amps (car (entsel "\nUpdate TOTAL DEMAND AMPS: ")))))
(setq amps (entget amps))
(if (eq (cdr (assoc 0 amps)) "TEXT")
   (entmod (setq amps (subst (cons 1 (rtos (/ total volts) 2 1)) (assoc 1 amps) amps)))
   (progn
       (princ "\nWrong Selection - Not Text!!")
       (exit)
   )
)

(princ)

)
页: [1] 2
查看完整版本: 需求电流Lisp