尼古拉斯,我明白你在找什么。我使用的方法将为您提供大部分但不是所有您正在寻找的内容。经验丰富的程序员可能会认为它冗长乏味,但它对我来说很有效。我制作了一个工具按钮并应用了一个宏。
宏是
^C^C_pdmode 3;_scale all; 0,0 0.1;_centroid;\_massp;\scale all; 0,0 10;_modulus;\;0,0;;;
需要将以下内容加载到图形中:-
附加的“massP”lisp例程
MassP。lsp
质心。此处提供vlxhttp://www.cadstudio.cz/en/download.asp?file=Centroid+%二维+绘图+重心+重力+28CG%2FCOG%29+点+多段线+2C+面域+或+三维+实体+28VLX+Lisp+for+AutoCAD%29
最后
你的模数。vlx(注意,正如模数自述文件中所建议的,您需要预设乘法因子,因此:-
(setq modKoef 0.001)
这将把你的读出单位设置为厘米3
使您的配置文件成为一个区域运行宏,并在每次提示时拾取该区域。(3次)
这给出了很多你想要的东西,但除了截面模量,没有列出单位。
幸运的是,这里的一些经验丰富的程序员将把这视为一个挑战,并为我们改进它。
编辑:用于参考模数。vlx可以在这里找到http://www.cadforum.cz/cadforum_en/download.asp?fileID=1016 你好,马尼拉·沃尔夫,
谢谢你那些有用的提示。我一直在使用质心和massP,以及模数和acaddoc中的新设置。lsp在过去几周有效。我强烈推荐这些应用程序,尤其是在需要进行多次MOI和截面模量计算的情况下。然而,我注意到质心确实复制了区域对象。你如何应对这种情况?过度杀戮是否足以同时应用于所有地区?还有Lisp程序吗?
当做
尼古拉斯。 嗨,尼古拉斯,
我确实遇到了同样的问题,因为该区域是重复的。
我对我的方法做了一些改变。
首先,在另外一两个帖子中,我得到了Cadtutor普通用户“PBe”的大力帮助,对此我感激不尽。
所以,我做了三件事,我使用了不同的mass props lisp并引入了“dupdel.lsp”来删除重复区域。我还添加了一个称为“Calcwt.lsp”的权重计算例程(pBe帮助)。质心。不需要vlx。
我的宏现在显示如下:-
^C^C_pdmode 3;TEXTSIZE 0.25 _scale all; 0,0 0.1;'_zoom e;;.9x;re;_MPcm;\_scale all; 0,0 10;'_zoom e;;.9x;TEXTSIZE 2.5 re;^C^C(setq modKoef 0.000001);(setq modSuf " cm3");^C^C_modulus;\;0,0;;;_dupdel;r a ;;re;^C^C(setq modKoef 1);(setq modSuf " mm3");_CalcWT;
我确信所有这些都可以简化成lisp,但遗憾的是,我没有lisp知识来做这件事。在第一次运行宏后,我仍然需要手动拾取同一个区域对象3次。当然也没有错误捕获。
与您类似,我将所有lisp例程都放在我的acaddoc中。lsp。
选择宏:-
1).
调用的第一个lisp是“MPcm.lsp”,它将粘贴到缩放对象上的massprops文本中,并将基于cm的单位添加到文本中。它还放置和显示质心。(我首先缩小区域对象,因为我总是以毫米为单位绘制)。
2).
第二个lisp调用的是“模数.vlx”,我看到你很熟悉。我注意到,当第一次运行时,加载可能需要几秒钟。
3).
调用的第三个lisp是“duppel.lsp”。这是免费提供的,作者的名字在lisp中,所以我认为可以在这里发布。这将删除重复的对象,我的宏将其设置为仅删除重复区域。
4).
调用的第四个lisp是“Calcwt.lsp”。这使我可以选择材质类型,然后列出我选择的图形中某个点的权重。我更新了这个lisp,列出了我实际上最常用的常用材料。
有点复杂,但它确实给了我想要的最终结果。
总之,我认为您的问题的答案是“duppel.lsp”仅设置为区域,但我列出的其他lisp可能也对您有用。
MPcm。lsp
CalcWt。LSP
杜普德尔。lsp 我的宏在图形中有多个对象时会变得有点凌乱,所以我改进了缩放。
现在我必须选择相同的区域4次,而不是3次,但它在屏幕上效果更好。
^C^C(alert "NOTE: - Select the same REGION each time you are prompted (4 times total)")(setq ss1 (ssget));\;_pdmode 3;TEXTSIZE 0.25 _scale all; 0,0 0.1;'_zoom o !ss1;;'_zoom .9x;re;_MPcm;\_scale all; 0,0 10;'_zoom o !ss1;;'zoom .8x;TEXTSIZE 2.5 re;^C^C(setq modKoef 0.001);(setq modSuf " cm3");^C^C_modulus;\;0,0;;;_dupdel;r a ;;re;^C^C(setq modKoef 1);(setq modSuf " mm3");_CalcWT;
我确实尝试将最初选择的区域设置为记忆对象,以便每次都可以自动调用,但宏中的三个LISP似乎不允许在从宏调用时使用这种选择方法。因此选择了4次。虽然不是百分之百完美,但它对我来说很管用。 哎呀!我在宏中发现了一个错误。我已经通过编辑更正了上面的宏。
(setq modKoef 0.000001)是模量的不正确缩放。正确的比例为(setq modKoef 0.001)
这确实是一种特殊的需求,但我相信我们很多人都有这种需求。我曾经拥有一个简单的LISP程序,它做得很好。它在编译的所有数据周围画了一个漂亮的矩形,给了你重量/英尺、截面属性、作品,甚至还提前问你是在做钢还是铝。我很久以前就丢了剧本,写剧本的那位先生后来去世了。几周前,我开始做这方面的工作,但忙于其他任务。我仍然沉浸在这份新的合同任务中,但我想接受这份任务,并把它贡献给论坛。这里的每个人都慷慨地帮助了我,我认为这是我能做的最起码的事情,我相信我会学到一两件事。我们很快就会报告。
再次感谢大家让这个论坛成为一个保持思想年轻的好地方。
我认为你对这项法案的看法是正确的。Massprop是一个很好的功能,我相信截面模量是最有用的,我正在尽我所能与Massprop携手自动生成截面模量,以及 I found this lisp buried deep in my hard drive. It appears to calculate the section modulus. The problem is that I can't get the lisp to run!
I wonder if anybody can help by explaining why it won't run. I would be grateful.
;;; --------------------------------------------------------------------------;;; MASSCAL.LSP modified from ASCTEXT.LSP & BONG'S LISP;;; --------------------------------------------------------------------------;;;; modified by Eric Wong;;; modified by Bong - May 1997;;; This program superseeds MP1 and MP2.LSP. Thanks to Eric Wong. - bong;;;;;; add weight November 1998;;; Save modes;;;;;; provide lower and upper Zx/Zy value;;; 21 Apr 1999(defun MODES (a)(setq MLST ' ()) (repeat (length a) (setq MLST (append MLST (list (list (car a) (getvar (car a)))))) (setq a (cdr a)) )) ;;;;;; Restore modes;;;(defun MODER ()(repeat (length MLST) (setvar (caar MLST) (cadar MLST)) (setq MLST (cdr MLST)) )) ;;;;;; Ascii Text error handler;;;(defun at_err (st) ; If an error (such as CTRL-C) occurs ; while this command is active... (if (/= st "Function cancelled") (princ (strcat "\nError: " st)) )(moder) ; Restore modified modes (if (= (type rtfile) 'FILE) (close rtfile) )(setq rtfile nil) (setq *error* olderr) ; Restore old *error* handler (princ)) ;;;;;; Read file line by line and store them;;;(defun readtxt1 (rf / rtfile txt txt1 txt2 txt3 txt4 txt5 txt6 txt7 txt8 txt11 txt12 txt13 txt 14 txt15 txt16 xcen ycen xmin ymin) (setq rtfile (open rf "r")) (setq txt (read-line rtfile)) ;- space file header (setq txt1 (read-line rtfile) ;- type of entity txt2 (read-line rtfile) ;- space txt3 (read-line rtfile) ;- area txt4 (read-line rtfile) ;- perimeter txt5 (read-line rtfile) ;- Bounding box x txt6 (read-line rtfile) ;- Bounding box y txt7 (read-line rtfile) ;- centroid-X txt8 (read-line rtfile) ;- centroid-Y txt9 (read-line rtfile) ;- MOI x txt10 (read-line rtfile) ;- MOI y txt11 (read-line rtfile) ;- POI x & y txt12 (read-line rtfile) ;- ROG x txt13 (read-line rtfile) ;- ROG y txt14 (read-line rtfile) ;- PM heading txt15 (read-line rtfile) ;- PM I txt16 (read-line rtfile) ;- PM J ) ; setq (close rtfile) (setq rtfile nil) (setq xmax (nth 5 (read (strcat "(" txt5 ")"))) ymax (nth 3 (read (strcat "(" txt6 ")"))) xmax2 (nth 3 (read (strcat "(" txt5 ")"))) ymax2 (nth 1 (read (strcat "(" txt6 ")"))) xmin (nth 3 (read (strcat "(" txt5 ")"))) ymin (nth 1 (read (strcat "(" txt6 ")"))) xcen (nth 2 (read (strcat "(" txt7 ")"))) ycen (nth 1 (read (strcat "(" txt8 ")"))) xycen (list xcen ycen) xstr (polar (list xmin ycen) (dtr 180) (* 5 h)) xend (polar (list xmax ycen) (dtr 0) (* 4 h)) ystr (polar (list xcen ymin) (dtr -90) (* 4 h)) yend (polar (list xcen ymax) (dtr 90) (* 4 h));;;; add weight wht (* 0.00271 (nth 1 (read (strcat "(" txt3 ")" )))) ));;;;;; Read file line by line and paste them;;;(defun readtxt2 (rf / s eof) (setq rtfile (open rf "r")) (setq eof nil) (while (null eof) (setq s (read-line rtfile)) (if s (progn (command "TEXT" pt1 h ang s) (setq pt1 (polar pt1 (dtr -90) (* 1.666 h))) ) (setq eof T) );if ) (close rtfile) (setq rtfile nil)) ;;;;;; -------------------------- MAIN PROGRAM -------------------------;;;(defun masstxt (ep1 / olderr ang eof rf h llea pt pt1 s xycen xstr xend ystr yend xmax ymax i j Zx Zy s1 s2 txt9 txt10)(setq olderr *error* *error* at_err) (modes '("BLIPMODE" "CMDECHO" "HIGHLIGHT" "CLAYER")) (setq rf (strcat (getvar "dwgname") ".mpr")) ;; Prompt for start point (while (null pt) (setq pt (getpoint "\nStart point : ")) (if (not pt) (princ " no point picked, try again")) ) (setq pt1 pt) ; First insertion point;;;; modified: 06 May 1997 (walang o-r-a-s);;; set text style(setq oldsty (getvar "textstyle"))(if (= (tblsearch "STYLE" "MONOTXT") nil) (command "style" "monotxt" "monotxt" "" "" "" "" "" "") (setvar "textstyle" "monotxt") ); if monostyle ;; Prompt for a text height (setvar "textsize" (* 2.75 (getvar "dimscale")));;; turn off by bong;;;(setq h (getdist pt (strcat "\nHeight : ")));;;(if (not h) (setq h (getvar "TEXTSIZE"));;;) (setq ang 0) (setvar "BLIPMODE" 0) (setvar "HIGHLIGHT" 0) (setvar "CMDECHO" 0);***************************************************************** (cond ((and *debug* (/= 0 *debug*)) (setq *error* nil) (setvar "cmdecho" 1)));*****************************************************************;;; turn off by bong. (if (= llea nil) (command ".layer" "M" "massprop" "c" "3" "" "") (command ".layer" "c" "3" "massprop" "") ) (setvar "clayer" "massprop") (readtxt1 rf) (if (= (tblsearch "ltype" "center2") nil) (command "linetype" "l" "center2" "acad" "")) (setvar "cecolor" "9") (setvar "celtype" "center2") (command ".line" xstr xend "" ".line" ystr yend "") (setvar "cecolor" "BYLAYER") (setvar "celtype" "BYLAYER") (command ".text" (polar xend (dtr 135) (* h 2)) (* h 1.5)"" "X") (command ".text" (polar yend (dtr -45) (* h 2)) (* h 1.5)"" "Y") (command ".copy" ep1 "" xycen "0,0") (command "massprop" (entlast) "" "Y" (getvar "dwgname")) (command ".erase" (entlast) "" ".redraw") (readtxt1 rf) (readtxt2 rf) (setq i (nth 4 (read (strcat "(" txt9 ")"))) j (nth 1 (read (strcat "(" txt10 ")"))) Zx (/ i ymax) Zy (/ j xmax) Zx2(/ i (abs ymax2)) Zy2(/ j (abs xmax2)) s1 (strcat "Modulus of Elasticity:Zx1 = " (rtos Zx 2 0) " Zx2 = " (rtos Zx2 2 0)) s2 (strcat " Zy1 = " (rtos Zy 2 0) " Zy2 = " (rtos Zy2 2 0)) ) (command ".text" pt1 h ang s1) (command ".text" (polar pt1 (dtr -90) (* 1.666 h)) h ang s2) (command ".text" (polar pt1 (dtr -90) (* 3.32 h)) h ang (strcat "Estimated Weight (Alum): " (rtos wht) "kg/m" )) (moder) ; Restore modified modes (setq *error* olderr) ; Restore old *error* handler (princ) (setvar "textstyle" oldsty)) ;;;;;; COMMAND declaration;;;(defun c:masscal (/ ep1 prela preco) (vmon) (setq ep1 nil) (while (= ep1 nil) (setq ep1 (entsel)) (if (null ep1) (princ "no object selected\n")) ) (if (/= "REGION" (cdr (assoc 0 (entget (car ep1))))) (progn (setq prela (cdr (assoc 8 (entget (car ep1)))) preco (cdr (assoc 62 (entget (car ep1)))) ) (if (= preco nil) (setq preco "BYLAYER")) (COMMAND "REGION" ep1 "") (COMMAND "CHPROP" (entlast) "" "la" prela "c" preco "") (setq ep1 (entlast)) ) (progn (princ "\n\tThe Object is REGION\n") (princ)) ) (COMMAND "MASSPROP" ep1 "" "Y" (getvar "dwgname")) (masstxt ep1)(princ)) (dos_delete (strcat (getvar "dwgname") ".mpr"))(defun C:MC ()(C:MASSCAL))(princ "\n\tc:MASSCAL v1.1 loaded! - Extrussion Weight Added!")(princ) This looks to be from about the time my old friend was working with LISP file for MASSPROP information which was the mid to late 1990's. Actually I think it was more like 1994 when I first ran into a MASSPROP lisp utility. I have only examined this briefly but the first thing I see is that there is a space between txt and 14 in the local variables called out in readtxt1 function. But even with fixing that, my copy of AutoCAD VLISP 2012 does not recognize the command "dos_delete". Haven't read much about this except that it's perhaps a module from another old group of LISP routines which was used way back. Even with commenting this line out the program crashes when it's trying to read the mpr file it created. I will have to spend more time looking at this. It does look very similar to the one I was searching from from my old DOS days as well. I have seen this referenced in the last few weeks but didn't run into in more depth until today. The above LISP file calls it and today I was asked to look at some older code authored by a previous employee and it calls DOS_DELETE in it. Of course this machine which is running Windows XP with ACAD 2002 just crashes saying it cannot find the function DOS_DELETE.
Can anyone clue me in on this? Is it something that is obsolete now...?
Google and yahoo have nothing about how this relates to AutoLISP which is surprising. Lots of DOS stuff and DoS attack stuff, but so far nothing which relates it AutoLISP has been found. Okay, I at least found DOSLib which I guess is no longer shipped with AutoCAD...so what took it's place or is all this code just so much junk now?
UPDATE: Ok, cool, I found the URL for the DOSLIB files. Had to get an old version of it as well as I had to find a site in Germany which had the etv1-9.exe file still available for free download. This code was written long ago in a galaxy far, far away. Now they want to dust it off and deploy it in a live setting again. More work for me so I won't complain.
页:
1
[2]