andreiprundeanu Posted August 21, 2023 Share Posted August 21, 2023 Designing an algorithm and creating a computer application for determining the centers of gravity for a die and calculating the center of pressure of cold forming equipmen*06 Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted August 21, 2023 Share Posted August 21, 2023 attached Example drawing Quote Link to comment Share on other sites More sharing options...
andreiprundeanu Posted August 21, 2023 Author Share Posted August 21, 2023 I send a private message here are the link with pictures: https://we.tl/t-4I7SsqW7af Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 21, 2023 Share Posted August 21, 2023 Helping you create something - is this somethng you do just now manually and in which case, what is the procedure you use -write down the steps you use and then it becomes a lot easier Quote Link to comment Share on other sites More sharing options...
andreiprundeanu Posted August 21, 2023 Author Share Posted August 21, 2023 (edited) Basically I need What is the code for Creating an algorithm and developing a computer application to determine the centers of gravity for a cylindrical or prismatic-shaped bar and calculate the center of pressure for cold forming equipment using AutoCAD LISP. I dont know the code is work and is good (defun c:CalculateCenters () (setq num-parts (getint "\nEnter the number of parts: ")) (setq parts '()) (repeat num-parts (setq shape (getstring "\nEnter shape (cylindrical/prismatic) for part " (itoa (+ 1 num-parts)) ": ")) (setq mass (getreal (strcat "\nEnter mass of part " (itoa (+ 1 num-parts)) ": "))) (setq x (getreal (strcat "\nEnter x-coordinate of part " (itoa (+ 1 num-parts)) ": "))) (setq y (getreal (strcat "\nEnter y-coordinate of part " (itoa (+ 1 num-parts)) ": "))) (setq parts (cons (list shape mass x y) parts))) (setq forces '()) (setq distances '()) (repeat num-parts (setq force (getreal (strcat "\nEnter force " (itoa (+ 1 num-parts)) " applied: "))) (setq distance (getreal (strcat "\nEnter distance " (itoa (+ 1 num-parts)) " from reference point: "))) (setq forces (cons force forces)) (setq distances (cons distance distances))) ;; Call functions to calculate centers of gravity and pressure (setq center-of-gravity (calculate-center-of-gravity parts)) (setq center-of-pressure (calculate-center-of-pressure forces distances)) (alert (strcat "Center of Gravity:\nX: " (rtos (car center-of-gravity) 2 2) "\nY: " (rtos (cadr center-of-gravity) 2 2))) (alert (strcat "Center of Pressure: " (rtos center-of-pressure 2 2))) ) (defun calculate-center-of-gravity (parts) ;; Calculate center of gravity logic ;; Modify this function based on your shape-specific calculations (setq total-mass (apply '+ (mapcar 'cadr parts))) (setq weighted-sum-x (apply '+ (mapcar (lambda (part) (* (cadr part) (caddr part))) parts))) (setq weighted-sum-y (apply '+ (mapcar (lambda (part) (* (cadr part) (cadddr part))) parts))) (list (/ weighted-sum-x total-mass) (/ weighted-sum-y total-mass)) ) (defun calculate-center-of-pressure (forces distances) ;; Calculate center of pressure logic ;; Modify this function based on your specific calculation requirements (setq total-force (apply '+ forces)) (setq weighted-sum (apply '+ (mapcar '* forces distances))) (/ weighted-sum total-force) ) Edited August 21, 2023 by SLW210 Added Code Tags! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted August 21, 2023 Share Posted August 21, 2023 Please use Code Tags for your Code (<> in the reply toolbar). Quote Link to comment Share on other sites More sharing options...
devitg Posted August 21, 2023 Share Posted August 21, 2023 45 minutes ago, andreiprundeanu said: Basically I need What is the code for Creating an algorithm and developing a computer application to determine the centers of gravity for a cylindrical or prismatic-shaped bar and calculate the center of pressure for cold forming equipment using AutoCAD LISP. I dont know the code is work and is good (defun c:CalculateCenters () (setq num-parts (getint "\nEnter the number of parts: ")) (setq parts '()) (repeat num-parts (setq shape (getstring "\nEnter shape (cylindrical/prismatic) for part " (itoa (+ 1 num-parts)) ": ")) (setq mass (getreal (strcat "\nEnter mass of part " (itoa (+ 1 num-parts)) ": "))) (setq x (getreal (strcat "\nEnter x-coordinate of part " (itoa (+ 1 num-parts)) ": "))) (setq y (getreal (strcat "\nEnter y-coordinate of part " (itoa (+ 1 num-parts)) ": "))) (setq parts (cons (list shape mass x y) parts))) (setq forces '()) (setq distances '()) (repeat num-parts (setq force (getreal (strcat "\nEnter force " (itoa (+ 1 num-parts)) " applied: "))) (setq distance (getreal (strcat "\nEnter distance " (itoa (+ 1 num-parts)) " from reference point: "))) (setq forces (cons force forces)) (setq distances (cons distance distances))) ;; Call functions to calculate centers of gravity and pressure (setq center-of-gravity (calculate-center-of-gravity parts)) (setq center-of-pressure (calculate-center-of-pressure forces distances)) (alert (strcat "Center of Gravity:\nX: " (rtos (car center-of-gravity) 2 2) "\nY: " (rtos (cadr center-of-gravity) 2 2))) (alert (strcat "Center of Pressure: " (rtos center-of-pressure 2 2))) ) (defun calculate-center-of-gravity (parts) ;; Calculate center of gravity logic ;; Modify this function based on your shape-specific calculations (setq total-mass (apply '+ (mapcar 'cadr parts))) (setq weighted-sum-x (apply '+ (mapcar (lambda (part) (* (cadr part) (caddr part))) parts))) (setq weighted-sum-y (apply '+ (mapcar (lambda (part) (* (cadr part) (cadddr part))) parts))) (list (/ weighted-sum-x total-mass) (/ weighted-sum-y total-mass)) ) (defun calculate-center-of-pressure (forces distances) ;; Calculate center of pressure logic ;; Modify this function based on your specific calculation requirements (setq total-force (apply '+ forces)) (setq weighted-sum (apply '+ (mapcar '* forces distances))) (/ weighted-sum total-force) ) @andreiprundeanu as far as I know , gravity center can be get direct from acad. . also the center of pressure please upload a sample.DWG 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.