Jump to content

cog of a set of scattered lines


nithink55

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

COG group lines.jpg

Link to comment
Share on other sites

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 :cry:

Link to comment
Share on other sites

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)
 )

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...