Autolisp坡度
你好我试图找到一个lisp,它获取2个块的属性“COTA”标记的值。以及这些区块之间的距离。
然后计算斜率。
我有一个类似的代码。但不要获取属性值。
(defun c:lp (/ ptoy dist altu perc)
(setq ptox (getpoint "\nClick first point: "))
(setq ptoy (getpoint "\nClick second point: "))
(setq dist (rtos (distance ptox ptoy) 2 2))
(setq altu (- (cadr ptoy) (cadr ptox)))
(setq perc (rtos (* (/ altu (atof dist)) 100) 2 2))
(princ (strcat "Distance = " dist " ; Perc = " perc "%"))
(princ)
);defun
请参阅附件。
它更好地解释了我的任务。
当做
e、 g.dwg
(defun c:lp2 (/ _sel val b1 b2 f pt e_ diff distB)
(defun _addComma (str sp / a b m i lst)
(if (numberp (read str))
(progn
(setq a (vl-filename-base str)
b (substr str (1+ (strlen a)))
m (vl-string->list a)
i (length m)
lst nil
)
(while (>= i 3)
(setq lst (append (list sp
(nth (- i 3) m)
(nth (- i 2) m)
(nth (1- i) m)
)
lst
)
i (- i 3)
)
lst
)
(strcat (substr str 1 i)
(vl-list->string
(if (zerop i)
(cdr lst)
lst
)
)
;;; mod
(if b (vl-string-subst "," "." b) "")
;; mod
)
)
)
)
(Defun _sel (msg / sel)
(princ (Strcat "\n<<Select " msg " Data>>"))
(While (null sel)
(setq sel (ssget "_:S" '((0 . "INSERT")(2 . "SIMB_BOLINHA")))))
(ssname sel 0))
(if
(And (setq val nil
b1(_sel "First")
b2(_sel "Second")
)
(foreach e (list b1 b2)
(setq fnil
pt (cdr (Assoc 10 (entget e)))
)
(if (and
(while
(and
(null f)
(eq (cdr (assoc 0 (setq e_ (entget (setq e (entnext e))))))
"ATTRIB"
)
)
(if (eq "COTA" (strcase (cdr (assoc 2 e_))))
(Setq f (cdr (Assoc 1 e_)))
)
)
(progn
(While (vl-string-position 46 f)
(setq f (vl-string-subst"" "." f)))
(setq f (distof (vl-string-subst "." "," f)))
(numberp f))
)
(setq val (cons (list f pt) val)
)
)
)
(vl-every '(lambda ( x ) x )(apply 'append val))
(= (length val) 2)
)
(alert (Strcat "\nSlope: " (rtos (* (/ (setq diff (abs (- (Caar val) (caadr val))))
(setq distB (distance (cadar val) (cadadr val)))
)
100.00
)
2
2
)
"%" " \nDifference of Elevation: " (_addComma (rtos diff 2 2) 46)
" \nDistance between BLocks: " (_addComma (rtos distB 2 2) 46)
)
)(princ "\n<<<Missing Information, Check Attribute Value>>>:")
)
(princ)
)
不使用[根据您的公式]结果的准确性 我对结果印象深刻。
这正是我想要的。
非常感谢您的快速回复和精彩代码。
:值得注意:
顺致敬意,
不客气,很高兴它对你有用。
干杯 你好
我试图在代码中添加另外两个信息,除了斜率(%)。
-不均匀度(890,00-891,30)=1.30
-距离(两个块之间的距离)
在我的绘图中,大约有三种块,但属性是相同的“COTA”,lisp仅适用于SIMB_BOLINHA块。
是否可以在代码中添加其他名称,SIMB_PONTO,SIMB_CRUZETA?
任何帮助都会很好的来吧,伙计们。
提前感谢。
那是什么?海拔的差异?什么格式?
(setq sel (ssget "_:S" '((0 . "INSERT")(2 . "SIMB_BOLINHA,SIMB_PONTO,SIMB_CRUZETA")))) (setq sel (ssget "_:S" '((0 . "INSERT")(2 . "SIMB_BOLINHA,SIMB_PONTO,SIMB_CRUZETA"))))
哦我这样做了,但我忘记了逗号。非常感谢。
是的,pBe。这是海拔的差异。
格式为十进制(在巴西,十进制标记为逗号。)
当做 你好,pBe
我不想给你带来不便,我想再问你一件事。
我需要在代码中加入另外两个信息,除了斜率(%)。
-高程差
-块之间的距离。
如果你能帮助我,我将非常感激,我真的需要代码中的这些信息。
提前感谢
我已经在一周前Madruga_SP.->[上一次由pBe编辑;2013年5月27日上午09:57]的#6号帖子上做了修改 你好,pBe
我注意到你更新了代码。
现在,我知道了,因为没用。
当为千单位时,属性值由句点“”分隔
e、 g 1.200,00
对不起打扰你了,最后一次你能帮我吗?
我向你保证。
页:
[1]
2