乐筑天下

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

[编程交流] 调用函数

[复制链接]

22

主题

55

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
110
发表于 2022-7-6 00:01:13 | 显示全部楼层 |阅读模式
请帮忙。
这让我疯狂。为什么我不能在此例程中调用预定义函数(getcent1)?它可以在命令行中正常工作。
 
我错过了什么?我得到*无效选择*
 
  1. (defun C:setvaluesCP (/)
  2.    (if (not (member matmixvalue '("Y" "N")))
  3.        (setq matmixvalue "Y")
  4.    );end if
  5.    (initget "Y N")
  6.        (setq choice72 (getkword (strcat "\nMaterial types - mixed?: [Yes/No] <" matmixvalue ">: ")))
  7.            (if (not (member choice72 '("Y" "N")))
  8.                (setq choice72 mamixvalue)
  9.                (setq matmixvalue choice72)
  10.            );end if
  11. ;-----------------------------------------------------------------------------------
  12.    
  13. (defun getcentcp1 (/)
  14.    (setq regns (ssadd))
  15.    
  16.    (progn
  17.        (princ "\n(A)luminium, stru(C)tural steel, (S)tainless steel")
  18.        (setq matype1 (getstring "\n1st material type: A,C or S"))
  19.        (setq regn1 (entsel "\nSelect 1st polyline: "))
  20.        (command "region" regn1 "")
  21.            (setq regn1 (entlast))
  22.                (setq fnCP1 "V:/AProps/secpropsCP1.mpr")
  23.                (command "massprop" regn1 "" "y" fnCP1)
  24.            (ssadd regn1 regns)
  25.    );end progn
  26.    (progn
  27.        (princ "\n(A)luminium, stru(C)tural steel, (S)tainless steel")
  28.        (setq matype2 (getstring "\n2nd material type: "))
  29.        (setq regn2 (entsel "\nSelect 2nd polyline: "))
  30.        (command "region" regn2 "")
  31.            (setq regn2 (entnext regn1))
  32.                (setq fnCP2 "V:/AProps/secpropsCP2.mpr")
  33.                (command "massprop" regn2 "" "y" fnCP2)
  34.            (ssadd regn2 regns)
  35.    );end progn
  36.    (command "union" regns "")
  37.    
  38. (princ)
  39. );end defun
  40. ;------------------------------------------------------------------------------
  41.    
  42. (defun getcentcp2 (/)
  43.    (setq regns (ssadd))
  44.    
  45.    (progn
  46.        (princ "\nSelect 1st polyline: ")
  47.        (setq regn1 (ssget '((0 . "Polyline"))))
  48.        (command "region" regn1 "")
  49.            (setq regn1 (entlast))
  50.                (setq fnCP1 "V:/AProps/secpropsCP1.mpr")
  51.                (command "massprop" regn1 "" "y" fnCP1)
  52.            (ssadd regn1 regns)
  53.    );end progn
  54.    (progn
  55.        (princ "\nSelect 2nd polyline: ")
  56.        (setq regn2 (ssget '((0 . "Polyline"))))
  57.        (command "region" regn2 "")
  58.            (setq regn2 (entnext regn1))
  59.                (setq fnCP2 "V:/AProps/secpropsCP2.mpr")
  60.                (command "massprop" regn2 "" "y" fnCP2)
  61.            (ssadd regn2 regns)
  62.    );end progn
  63.    (command "union" regns "")
  64. (princ)
  65. );end defun
  66. ;----------------------------------------------------------------------------------------------
  67.    (if    (= choice72 "Y")
  68.        (getcentcp1)
  69.        (getcentcp2)
  70.    );end if
  71. (princ)   
  72. );end defun
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 00:43:50 | 显示全部楼层
请检查返回的条目:
  1. (setq regn1 (entsel "\nSelect 1st polyline: "))
  2. (command "region" [color=red](car [/color]regn1[color=red])[/color] "")
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 01:25:40 | 显示全部楼层
此外,关于第二个函数:
你确定是关于旧类型的多段线,而不是新类型的多段线吗?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 21:30 , Processed in 0.523971 second(s), 58 queries .

© 2020-2025 乐筑天下

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