Manila Wolf Posted February 12, 2015 Share Posted February 12, 2015 As usual, my thanks to you Tharwat. Cheers. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 I have updated the program in post no: #37 or from HERE and no more hyphens anymore with the new codes of parsing the strings . Give it a shot and let me know . Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted February 13, 2015 Share Posted February 13, 2015 Hi Tharwat, Nearly there I believe. I tested again and there seems that just one minor correction to the code is needed. Please see the attached drawing. It concerns the display only of the biggest bounding box values. It appears that the first value in the string rather than the largest value is displaying. I say the problem is with the display only because the program does appear to select the correct biggest value when calculating the section modulus values. Just thinking out loud, if the whole bounding box string i.e the maximum and minimum values complete with all the hyphens is displayed in the attribute then that is fine. Is that easier for coding? It would be fine for me because the section modulus values that use the biggest value are coming out correct. The above for your information. Cheers and Thanks. MassPropsTest-RevA.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 13, 2015 Share Posted February 13, 2015 Sorry I forgot about that max value , anyway I did modify the program and you can try it now . Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted February 13, 2015 Share Posted February 13, 2015 You totally nailed it Tharwat. A marvellous program. Sincere thanks. I will use it extensively. Cheers. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 13, 2015 Share Posted February 13, 2015 You totally nailed it Tharwat. A marvellous program. Sincere thanks. I will use it extensively. Cheers. Waw .. Excellent , Happy to hear that and you are most welcome I also learned a lot from writing this program programmatically and technically . Good luck . Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 12, 2017 Share Posted November 12, 2017 Dear Tharwat, please guide me how i convert the units of moment of inertia from mm4 to cm4? Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 _l (mapcar '(lambda (j k) (cons j k)) '("AREA" "PERIMETER" "BOUNDING_BOX_X_MAX" "BOUNDING_BOX_Y_MAX" "CENTROID_X" "CENTROID_Y" "MOMENT_OF_INERTIA_X" "MOMENT_OF_INERTIA_Y" "SECTION_MODULUS_ZX" "SECTION_MODULUS_ZY" "RADIUS_OF_GYRATION_X" "RADIUS_OF_GYRATION_Y" "WEIGHT" ) srt may be u should preset the multiplication factor for displayed results: (setq modKoef 0.001) some were here? Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted November 13, 2017 Share Posted November 13, 2017 In a simple way......... Assuming your profile is drawn using cm in lieu of mm, then you can arrive at the correct kg/m for aluminium extrusions by changing this line:- (rtos (* (read ar) 0.00271) 2 3) To (rtos (* (read ar) 0.271) 2 3) All the other mass property values are generated based on the size of the drawn profile. So if you have drawn the profile in cm units and with the centroid at position 0,0, then then all the resultant values should be correct. Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 the problem is that i need all the parameters leave as is but only the moment of inertia should be calculated in cm4 hence -the mass 0.00271 is fine. please guide me where to ad the 0.0001? Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted November 13, 2017 Share Posted November 13, 2017 the problem is that i need all the parameters leave as is but only the moment of inertia should be calculated in cm4hence -the mass 0.00271 is fine. please guide me where to ad the 0.0001? Ah! sorry, I misunderstood. so your profile is drawn in mm units. Apologies. The coding required is beyond my capabilities. Hopefully Tharwat will read this and may be able to help. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 13, 2017 Share Posted November 13, 2017 the problem is that i need all the parameters leave as is but only the moment of inertia should be calculated in cm4hence -the mass 0.00271 is fine. please guide me where to ad the 0.0001? Hi, The Moments of inertia are as follows in my previous posted program: X = (car p) Y = (cadr p) So just multiply the value with any factor that you would like to change to: eg: (* (car p) 0.0001) Hope this clear enough to you. Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 thanks - yes it is clear. just to be sure i use the last one - could you send the latest lisp of writemass.lsp? Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 my previous posted program: X = (car p) Y = (cadr p) i can`t find this line in your lisp Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 i understand that the line should be modified in this region: """"""0.0000" "0.0000" (car _l2) (cadr _l2) (rtos (/ (read (car _l2)) (max (read (caadr _l1)) (read (cadadr _l1)) ) ) 2 3 ) (rtos (/ (read (cadr _l2)) (max (read (caar _l1)) (read (cadar _l1)) ) ) 2 3 ) (caddr _l2) (nth 3 _l2) (rtos (* (read ar) 0.00271) 2 3) """ please guide me -in what line i should to interrupt? Quote Link to comment Share on other sites More sharing options...
SLW210 Posted November 13, 2017 Share Posted November 13, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 13, 2017 Share Posted November 13, 2017 "0.0000" "0.0000" (car _l2) (cadr _l2) (rtos (/ (read (car _l2)) (max (read (caadr _l1)) (read (cadadr _l1)) ) ) 2 3 ) (rtos (/ (read (cadr _l2)) (max (read (caar _l1)) (read (cadar _l1)) ) ) 2 3 ) (caddr _l2) (nth 3 _l2) (rtos (* (read ar) 0.00271) 2 3) so this is the part of the code - where i should put the 0.0001? Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 14, 2017 Share Posted November 14, 2017 please Help me to understand this issue. i need to modernize this lisp. 1. I need show moment of inertia I[xx];[yy] but in CM4; 2. I also i need add some parametr: Wx=Ixx*10/a1 (a1- promt to pic dimention value); Wy=Iyy*10/b1 (b1- promt to pic other dimention value); please See below the code copied from this topic (Big thanks for Tharwat): (defun c:WriteMass (/ *error* _get _doc cho f cl o b l _l _l1 _l2 ar srt fnd) ;;; ------------------------------------------------- ;;; ;;; ---=== { Author : Tharwat Al Shoufi } ===--- ;;; ;;; ;;; ;;; Write mass properties to Attributed Block(s) ;;; ;;; ------------------------------------------------- ;;; (setq _doc (vla-get-activedocument (vlax-get-acad-object))) (defun *error* (x) (if (and f (setq f (findfile f))) (vl-file-delete f) ) (if cho (setvar 'cmdecho cho) ) (if (and x (not (wcmatch (strcase x) "*BREAK*,*EXIT*,*CANCEL*")) ) (princ "Error:" x "...") ) ) ;;; ;;; (defun _get (f / of s lst l) (if (and (setq of (open f "r")) (while (setq s (read-line of)) (setq lst (cons s lst)) ) ) (progn (close of) (if (setq lst (reverse lst)) (mapcar '(lambda (i) (setq l (cons (nth i lst) l))) '(3 4 5 6 9 10 12 13) ) ) (setq l (reverse l)) ) ) l ) ;;; ;;; (cond ((or (minusp (cdr (assoc 62 (setq cl (entget (tblobjname "LAYER" (getvar 'CLAYER)) ) ) ) ) ) (= 4 (logand 4 (cdr (assoc 70 cl)))) ) (alert "<!> Current Layer is either OFF or LOCKED <!>") ) ((and (princ "\n Select CLOSED Object [REGION,CIRCLE,ELLIPSE,LWpolyline] :" ) (not (setq o (ssget "_+.:S:E:L" '((-4 . "<OR") (0 . "REGION,CIRCLE,ELLIPSE") (-4 . "<AND") (0 . "LWPOLYLINE") (-4 . "&=") (70 . 1) (-4 . "AND>") (-4 . "OR>") ) ) ) ) ) (alert "\n << nil or Invalid Object or on Locked Layer !! >>" ) ) ((and (princ "\n Select Attributed Block(s) :") (not (setq b (ssget "_:L" '((0 . "INSERT") (66 . 1))))) ) (alert "Invalid object . Should be Attributed Block(s) !") ) ) (if (and b (if (not (setq f (vl-filename-mktemp nil nil ".mpr"))) (alert "Can't create the text file !!") t ) ) (progn (if (eq (cdr (assoc 0 (entget (ssname o 0)))) "REGION") (setq r (list (vlax-ename->vla-object (ssname o 0)))) (setq r (vl-catch-all-apply 'vlax-invoke (list (vla-get-block (vla-get-activelayout (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) 'Addregion (list (vlax-ename->vla-object (ssname o 0))) ) ) d t ) ) (setq cho (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.ucs" "_Origin" (setq p (vlax-get (car r) 'Centroid)) ) (command "_.massprop" (vlax-vla-object->ename (car r)) "" "y" (vl-string-translate "\\" "/" f) ) (command "_.ucs" "w") (setvar 'cmdecho cho) (if d (vla-delete (car r)) ) (if (zerop (getvar 'PDMODE)) (setvar 'PDMODE 34) ) (entmake (list '(0 . "POINT") (cons 10 p) ) ) (if (setq l (_get f)) (progn (setq _l1 (mapcar '(lambda (s d / p a b c) (setq p (vl-string-search d s) a (vl-string-trim " " (substr s (+ p 3)) ) p (vl-string-search "--" a) b (substr a 1 p) c (vl-string-trim " " (substr a (+ p 3)) ) b (if (wcmatch b "-*") (substr b 2) b ) c (if (wcmatch c "-*") (substr c 2) c ) ) (mapcar '(lambda (x) (vl-string-trim " " x)) (list b c) ) ) (list (nth 2 l) (nth 3 l)) '("X:" "Y:") ) _l2 (mapcar '(lambda (s d / p a) (setq p (vl-string-search d s) a (vl-string-trim " " (substr (vl-string-trim " " (substr s (+ p 3)) ) 1 p ) ) ) a ) (list (nth 4 l) (nth 5 l) (nth 6 l) (nth 7 l) ) '("X:" "Y:" "X:" "Y:") ) ar (vl-string-trim " " (substr (car l) 6)) srt (list ar (vl-string-trim " " (substr (cadr l) 12)) (rtos (max (read (caar _l1)) (read (cadar _l1)) ) 2 3 ) (rtos (max (read (caadr _l1)) (read (cadadr _l1)) ) 2 3 ) "0.0000" "0.0000" (car _l2) (cadr _l2) (rtos (/ (read (car _l2)) (max (read (caadr _l1)) (read (cadadr _l1)) ) ) 2 3 ) (rtos (/ (read (cadr _l2)) (max (read (caar _l1)) (read (cadar _l1)) ) ) 2 3 ) (caddr _l2) (nth 3 _l2) (rtos (* (read ar) 0.00271) 2 3) ) _l (mapcar '(lambda (j k) (cons j k)) '("AREA" "PERIMETER" "BOUNDING_BOX_X_MAX" "BOUNDING_BOX_Y_MAX" "CENTROID_X" "CENTROID_Y" "MOMENT_OF_INERTIA_X" "MOMENT_OF_INERTIA_Y" "SECTION_MODULUS_ZX" "SECTION_MODULUS_ZY" "RADIUS_OF_GYRATION_X" "RADIUS_OF_GYRATION_Y" "WEIGHT" ) srt ) ) (vla-startUndomark _doc) ((lambda (n / sn) (while (setq sn (ssname b (setq n (1+ n)))) (mapcar '(lambda (x) (if (setq fnd (assoc (vla-get-tagstring x) _l ) ) (vla-put-textstring x (cdr fnd)) ) ) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes ) ) ) ) -1 ) (vla-endundomark _doc) ) ) ) ) (terpri) (*error* nil) (princ "\nThis Program is written by Tharwat Al Shoufi .") (princ) ) (vl-load-com) (princ "\n** Type WriteMass to start.. Author: Tharwat Al Shoufi .*" ) (princ) Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted November 15, 2017 Share Posted November 15, 2017 I think it would help people reading this thread if you were more clear about the units that you require. For example see the attached pic. A triangle drawn in millimetre units but the listed section properties are based on centimetre units. Is that what you are looking for? Or something else? Maybe if you use the same size triangle, then list the figures and units that you are hoping to see. Not sure if I can ultmately help you, but at least it will be more clear to others that may be able to help. Quote Link to comment Share on other sites More sharing options...
arkizner Posted November 15, 2017 Share Posted November 15, 2017 thank you Wolf, the calculating is for profile aluminium i use region with islands perimetr out - region (missing) perimetr total (what is exist in the lisp) is the total out+islands the units are in mm but only the moment of inertia i need in CM please see the pics Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.