乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 25|回复: 19

[编程交流] what's wrong in my code (

[复制链接]

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 06:30:04 | 显示全部楼层 |阅读模式
T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)]
A= Area of a polyline
L= Perimetr of a polyline
T= tolerance
 
I try to print the area and the perimetr but i have (syntax error) with
the print of T  and the (10% * Area)
 
The (10% * Area) is safety factor that why is important because
 
if (10% * Area) > T the the tolerance  is the T
and
if (10% * Area)
-------------------------------------------------------------
  1. (defun c:ktim ( / a l i s )   (if (setq s           (ssget              '(   (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")                   (-4 . "")               )           )       )       (progn           (setq a 0.0)           (repeat (setq i (sslength s))               (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i))))))           )      (progn           (setq l 0.0)           (repeat (setq i (sslength s))               (setq e (ssname s (setq i (1- i)))                     l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))               )           )           (princ "\nTotal Length: ")           (princ (rtos l 2 2))       )       (princ "\nTotal Area: ")           (princ (rtos a 2 2)))(princ "\n Tolerance: ")           (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4) 2 2)))(princ "\n 10 % Area : ")           (princ (rtos (* a 0.1) 2 2)))   )   (princ))(vl-load-com) (princ)
回复

使用道具 举报

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 06:36:22 | 显示全部楼层
please help i need this ...
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-6 06:37:56 | 显示全部楼层
Syntax errors in lisp programs are often a result of incorrect placement or number of parentheses.  Have you checked your code for such a likelihood?
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 06:39:47 | 显示全部楼层
  1. (defun c:ktim ( / a l i s e ) (if (setq s       (ssget        '( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")           (-4 . "")         )       )     )     (progn       (setq a 0.0)       (repeat (setq i (sslength s))         (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i))))))       )       (setq l 0.0)       (repeat (setq i (sslength s))         (setq e (ssname s (setq i (1- i)))               l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))         )       )     ) )  (princ "\nTotal Length: ") (princ (rtos l 2 2)) (princ "\nTotal Area: ") (princ (rtos a 2 2)) (princ "\nTolerance: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4)[highlight])[/highlight] 2 2)) (princ "\n10 % Area : ") (princ (rtos (* a 0.1) 2 2)) (princ))(vl-load-com) (princ)
You missed ) - see highlighted... And also you had extra ) after (princ...)
You also had invalid DXF 70 for 3dpolyline - it should be (70 .
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 06:44:40 | 显示全部楼层
I *think* this is what you're after:
  1. (defun c:ktim (/ a l i s) (if (setq s            (ssget              '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")                (-4 . "")               )            )     )   (progn     (setq a 0.0)     (repeat (setq i (sslength s))       (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i))))))     );;;      (progn     (setq l 0.0)     (repeat (setq i (sslength s))       (setq e (ssname s (setq i (1- i)))             l (+ l                  (vlax-curve-getdistatparam e (vlax-curve-getendparam e))               )       )     )     (princ "\nTotal Length: ")     (princ (rtos l 2 2));;;      )     (princ "\nTotal Area: ")     (princ (rtos a 2 2));;;    )     (princ "\n Tolerance: ")     (princ       (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1)) a) l)                (* (sqrt a) 4)                2                2             )       )     )     (princ "\n 10 % Area : ")     (princ (rtos (* a 0.1) 2 2))   ) ) (princ))(vl-load-com)(princ)
 
*not sure*
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 06:46:10 | 显示全部楼层
 
... Kind of hard to evaluate all of those PRINC calls, if the PROGN call never happens (due to s = Nil).
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 06:50:00 | 显示全部楼层
Has revised, here you go:
  1. (defun c:ktim ( / A E I L S)(vl-load-com)(setq s           (ssget              '(   (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")                    (-4 . "")               )           )       )(if (/= s nil)(progn (setq l 0.0 a 0.0 i 0)(while (< i (sslength s)) (progn               (setq e (ssname s i)                     l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))                     a (+ a (vlax-curve-getarea e)))) (setq i (1+ i)))           (princ "\nTotal Length: ")           (princ (rtos l 2))            (princ "\nTotal Area: ")           (princ (rtos a 2))           (princ "\n Tolerance: ")           (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4) 2 2)))            (princ "\n 10 % Area : ")           (princ (rtos (* a 0.1) 2 2))       )) (princ))
回复

使用道具 举报

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 06:52:57 | 显示全部楼层
i neeed something more  if it is posible
 
if the scale 1: 1000 we have this T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)]
if the scale 1: 5000 we have this  T = [((sqrtA) + 4)^ 2) - A] * [ L/( 4*(sqrtA)]
and for the two cases we have
 
if (10% * Area) > T the the tolerance is the T
and
if (10% * Area)
回复

使用道具 举报

107

主题

615

帖子

575

银币

中流砥柱

Rank: 25

铜币
521
发表于 2022-7-6 06:57:18 | 显示全部楼层
nice job but the calculation is wrong, any ideas ????????????
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 06:59:33 | 显示全部楼层
Really stabbing in the dark here (not sure I understand fully what you're trying to do), but building on my earlier code revision, give this a try:
 
  1. (defun c:ktim (/ cannoscale tval a l i s) (if (and       (setq tval (cond ((= "1" = 10000'"                            (setq cannoscale (getvar 'cannoscale))                         )                         2                        )                        ((= "1" = 50000'" cannoscale)                         4                        )                  )       )       (setq s              (ssget                '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")                  (-4 . "")                 )              )       )     )   (progn     (setq a 0.0)     (repeat (setq i (sslength s))       (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i))))))     );;;      (progn     (setq l 0.0)     (repeat (setq i (sslength s))       (setq e (ssname s (setq i (1- i)))             l (+ l                  (vlax-curve-getdistatparam e (vlax-curve-getendparam e))               )       )     )     (princ "\nTotal Length: ")     (princ (rtos l 2 2));;;      )     (princ "\nTotal Area: ")     (princ (rtos a 2 2));;;    )     ;;if the scale 1: 1000 we have this T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)]     ;;if the scale 1: 5000 we have this T = [((sqrtA) + 1)^ 4) - A] * [ L/( 4*(sqrtA)]     (princ "\n Tolerance: ")     (princ       (rtos         (* (- (* (+ 1 (sqrt a)) tval) a) (/ l (* (sqrt a) 4)))         2         2       );;;        (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1)) a) l);;;                 (* (sqrt a) 4);;;                 2;;;                 2;;;              );;;        )     )     (princ "\n 10 % Area : ")     (princ (rtos (* a 0.1) 2 2))   )   (cond (tval (prompt "\n** invalid selection ** "))         ((prompt "\n** Scale must be "1:1000" or "1:5000" ** "))   ) ) (princ))
 
** Note - This code assumes that your drawing's annotation scale is equal to the desired scale of either 1:1000, or 1:5000.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 15:10 , Processed in 1.444438 second(s), 83 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表