nithink55 Posted July 29, 2015 Share Posted July 29, 2015 Dear All Do you have any lisp program for finding cog of a set of scattered lines? cog to marked on drawing in circle Nithin Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 OK, you can stop now. Three threads all asking the same question is really quite enough. I'm still not sure what you are asking. Post an image or attach an actual DWG file. Quote Link to comment Share on other sites More sharing options...
nithink55 Posted July 29, 2015 Author Share Posted July 29, 2015 i have removed other posts sry. Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 What are you trying to draw? The only two definitions of "cog" that I am familiar with are the teeth on the rim of a gear or a tenon projecting from the end of a beam that fits into a mortise. If it is a math term it is one I am not familiar with. Quote Link to comment Share on other sites More sharing options...
nithink55 Posted July 29, 2015 Author Share Posted July 29, 2015 i need to find center of gravity of these lines. and the point to be marked as a circle Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 29, 2015 Share Posted July 29, 2015 I assume COG = Center of Gravity? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 29, 2015 Share Posted July 29, 2015 Create a region from the boundary using the REGION or BOUNDARY commands, and then query the mass properties of the region using MASSPROP. Alternatively, ask Google. Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 See post number 6 of this thread. http://www.cadtutor.net/forum/showthread.php?24528-Lisp-to-find-Center-of-Gravity Quote Link to comment Share on other sites More sharing options...
nithink55 Posted July 29, 2015 Author Share Posted July 29, 2015 then how to find center of gravity of these lines(attached) Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 Join them and create a region as per Lee Mac's suggestion? Quote Link to comment Share on other sites More sharing options...
nithink55 Posted July 29, 2015 Author Share Posted July 29, 2015 If i Join them and created a region, then i will get cog of the area right? but i need cog of these lines Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 There is no need to repeat a reply. You want the "cog" for individual lines or a group of lines? If it is a group of lines then I would consider the "group" to be a single entity thus Lee Mac's suggestion should apply. Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 29, 2015 Share Posted July 29, 2015 This is what I would do. Start with the original set of lines (white) as shown on the left. Add connecting lines (red) as shown in middle. Execute the REGION command to create region as shown (red) on the right. Run the MASSPROP command. Results shown in text box on far right. Quote Link to comment Share on other sites More sharing options...
eldon Posted July 29, 2015 Share Posted July 29, 2015 As the centre of gravity of each individual line is at its centre point, I am not sure that creating a region bounded by a projected length of each line would give the correct result. One would have to sum the moments of each line about the centre of gravity (wherever it was), so that the result was zero. It seems to me that that is not what AutoCAD is doing. AutoCAD can deal with areas, but this case would need to be dealing with some sort of space frame. My maths is not up to it Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted July 29, 2015 Share Posted July 29, 2015 A shot in the dark... (defun C:CGLIN ( / ss l i e p1 p2 d pm) (if (setq ss (ssget '((0 . "LINE")))) (progn (setq l '(0.0 0.0 0.0 0.0)) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i)))) p1 (cdr (assoc 10 e)) p2 (cdr (assoc 11 e)) d (distance p1 p2) pm (mapcar '(lambda (a b) (* (+ a b) 0.5 d)) p1 p2) ) (setq l (mapcar '+ l (cons d pm))) ) (entmake (list '(0 . "POINT") (cons 10 (mapcar '(lambda (a) (/ a (car l))) (cdr l))) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 29, 2015 Share Posted July 29, 2015 Perhaps the solutions in these two threads will work. http://www.cadtutor.net/forum/showthread.php?48143-LISP-to-find-midpoint-of-multiple-lines http://www.cadtutor.net/forum/showthread.php?49675-.NET-Find-COG-of-linear-elements 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.