Jump to content

[Help] Draw this bolts


ketxu

Recommended Posts

Please, please help me to drawing this with entmake or some command (Polygon, Circle, Pline or Arc). I've try with command, but i'm very very chicken in geometry ang bugle, i've problem with calculate coordinates, so it become a big problem...

(all dimension and two small circle+3/4 circle in center of bolt are not need,i just add to described. Input is D)

Thanks all for help

Untitled-4.jpg

Link to comment
Share on other sites

I'm trying to put in into one lisp code with DCL belong to D, or eventhough drawing it manualy then makeEntmake, then scale it as a block.. But, as i mention, i'm very very chicken in geometry :|

Link to comment
Share on other sites

So, could you help me how to entmake an arc through 3 point?

Here are my functions relating to 3-Point Arcs/Circles:

 

[color=GREEN];; 3-Point Arc  -  Lee Mac[/color]
[color=GREEN];; Returns the Center, Start/End Angle, Radius of the[/color]
[color=GREEN];; Arc defined by three supplied points.[/color]

([color=BLUE]defun[/color] LM:3PArc ( p1 p2 p3 [color=BLUE]/[/color] cn m1 m2 )
   ([color=BLUE]setq[/color] m1 (mid p1 p2)
         m2 (mid p2 p3)
   )
   ([color=BLUE]if[/color]
       ([color=BLUE]setq[/color] cn
           ([color=BLUE]inters[/color]
               m1 ([color=BLUE]polar[/color] m1 ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p1 p2) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.)) 1.0)
               m2 ([color=BLUE]polar[/color] m2 ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p2 p3) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.)) 1.0)
               [color=BLUE]nil[/color]
           )
       )
       ([color=BLUE]append[/color] ([color=BLUE]list[/color] cn)
           ([color=BLUE]if[/color] (LM:Clockwise-p p1 p2 p3)
               ([color=BLUE]list[/color] ([color=BLUE]angle[/color] cn p3) ([color=BLUE]angle[/color] cn p1))
               ([color=BLUE]list[/color] ([color=BLUE]angle[/color] cn p1) ([color=BLUE]angle[/color] cn p3))
           )
           ([color=BLUE]list[/color] ([color=BLUE]distance[/color] cn p1))
       )
   )
)

[color=GREEN];; 3-Point Circle  -  Lee Mac[/color]
[color=GREEN];; Returns the Center and Radius of the Circle defined[/color]
[color=GREEN];; by three supplied points.[/color]

([color=BLUE]defun[/color] LM:3PCircle ( p1 p2 p3 [color=BLUE]/[/color] cn m1 m2 )
   ([color=BLUE]setq[/color] m1 (mid p1 p2)
         m2 (mid p2 p3)
   )
   ([color=BLUE]if[/color]
       ([color=BLUE]setq[/color] cn
           ([color=BLUE]inters[/color]
               m1 ([color=BLUE]polar[/color] m1 ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p1 p2) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.)) 1.0)
               m2 ([color=BLUE]polar[/color] m2 ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p2 p3) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.)) 1.0)
               [color=BLUE]nil[/color]
           )
       )
       ([color=BLUE]list[/color] cn ([color=BLUE]distance[/color] cn p1))
   )
)

[color=GREEN];; Midpoint  -  Lee Mac[/color]
[color=GREEN];; Returns the midpoint of two points[/color]

([color=BLUE]defun[/color] mid ( a b )
   ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]/[/color] ([color=BLUE]+[/color] a b) 2.0))) a b)
)

[color=GREEN];; Clockwise-p  -  Lee Mac[/color]
[color=GREEN];; Returns T if p1,p2,p3 are clockwise oriented[/color]

([color=BLUE]defun[/color] LM:Clockwise-p ( p1 p2 p3 )
   ([color=BLUE]<[/color] ([color=BLUE]*[/color] ([color=BLUE]-[/color] ([color=BLUE]car[/color]  p2) ([color=BLUE]car[/color]  p1)) ([color=BLUE]-[/color] ([color=BLUE]cadr[/color] p3) ([color=BLUE]cadr[/color] p1)))
      ([color=BLUE]*[/color] ([color=BLUE]-[/color] ([color=BLUE]cadr[/color] p2) ([color=BLUE]cadr[/color] p1)) ([color=BLUE]-[/color] ([color=BLUE]car[/color]  p3) ([color=BLUE]car[/color]  p1)))
   )
)

 

Test Functions:

[color=GREEN];;  Test Functions[/color]

([color=BLUE]defun[/color] c:3PArc ( [color=BLUE]/[/color] p1 p2 p3 lst )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] p1  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color]))
           ([color=BLUE]setq[/color] p2  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 2nd Point: "[/color] p1))
           ([color=BLUE]setq[/color] p3  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 3rd Point: "[/color] p2))
           ([color=BLUE]setq[/color] lst (LM:3PArc ([color=BLUE]trans[/color] p1 1 0) ([color=BLUE]trans[/color] p2 1 0) ([color=BLUE]trans[/color] p3 1 0)))
       )
       ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] '((0 . [color=MAROON]"ARC"[/color])) ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 50 51 40) lst)))
   )
   ([color=BLUE]princ[/color])
)

([color=BLUE]defun[/color] c:3PCircle ( [color=BLUE]/[/color] p1 p2 p3 lst )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] p1  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color]))
           ([color=BLUE]setq[/color] p2  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 2nd Point: "[/color] p1))
           ([color=BLUE]setq[/color] p3  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 3rd Point: "[/color] p2))
           ([color=BLUE]setq[/color] lst (LM:3PCircle ([color=BLUE]trans[/color] p1 1 0) ([color=BLUE]trans[/color] p2 1 0) ([color=BLUE]trans[/color] p3 1 0)))
       )
       ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] '((0 . [color=MAROON]"CIRCLE"[/color])) ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 40) lst)))
   )
   ([color=BLUE]princ[/color])
)

 

Dynamic Test Functions:

[color=GREEN];; Dynamic Test Functions[/color]

([color=BLUE]defun[/color] c:3PGrArc ( [color=BLUE]/[/color] p1 p2 p3 lst arc )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] p1  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color]))
           ([color=BLUE]setq[/color] p2  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 2nd Point: "[/color] p1))
           ([color=BLUE]setq[/color] p3  ([color=BLUE]cadr[/color] ([color=BLUE]grread[/color] [color=BLUE]t[/color] 13 0)))
           ([color=BLUE]setq[/color] lst (LM:3PArc ([color=BLUE]setq[/color] p1 ([color=BLUE]trans[/color] p1 1 0)) ([color=BLUE]setq[/color] p2 ([color=BLUE]trans[/color] p2 1 0)) ([color=BLUE]trans[/color] p3 1 0)))
           ([color=BLUE]setq[/color] arc ([color=BLUE]entmakex[/color] ([color=BLUE]append[/color] '((0 . [color=MAROON]"ARC"[/color])) ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 50 51 40) lst))))
           ([color=BLUE]setq[/color] arc ([color=BLUE]list[/color] ([color=BLUE]cons[/color] -1 arc)))
           ([color=BLUE]princ[/color] [color=MAROON]"\nSpecify 3rd Point: "[/color])
       )
       ([color=BLUE]while[/color] ([color=BLUE]=[/color] 5 ([color=BLUE]car[/color] ([color=BLUE]setq[/color] gr ([color=BLUE]grread[/color] [color=BLUE]t[/color] 13 0))))
           ([color=BLUE]if[/color] ([color=BLUE]setq[/color] lst (LM:3PArc p1 p2 ([color=BLUE]trans[/color] ([color=BLUE]cadr[/color] gr) 1 0)))
               ([color=BLUE]entmod[/color] ([color=BLUE]append[/color] arc ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 50 51 40) lst)))
           )
       )
   )
   ([color=BLUE]princ[/color])
)

([color=BLUE]defun[/color] c:3PGrCircle ( [color=BLUE]/[/color] p1 p2 p3 lst cir )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] p1  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color]))
           ([color=BLUE]setq[/color] p2  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 2nd Point: "[/color] p1))
           ([color=BLUE]setq[/color] p3  ([color=BLUE]cadr[/color] ([color=BLUE]grread[/color] [color=BLUE]t[/color] 13 0)))
           ([color=BLUE]setq[/color] lst (LM:3PCircle ([color=BLUE]setq[/color] p1 ([color=BLUE]trans[/color] p1 1 0)) ([color=BLUE]setq[/color] p2 ([color=BLUE]trans[/color] p2 1 0)) ([color=BLUE]trans[/color] p3 1 0)))
           ([color=BLUE]setq[/color] cir ([color=BLUE]entmakex[/color] ([color=BLUE]append[/color] '((0 . [color=MAROON]"CIRCLE"[/color])) ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 40) lst))))
           ([color=BLUE]setq[/color] cir ([color=BLUE]list[/color] ([color=BLUE]cons[/color] -1 cir)))
           ([color=BLUE]princ[/color] [color=MAROON]"\nSpecify 3rd Point: "[/color])
       )
       ([color=BLUE]while[/color] ([color=BLUE]=[/color] 5 ([color=BLUE]car[/color] ([color=BLUE]setq[/color] gr ([color=BLUE]grread[/color] [color=BLUE]t[/color] 13 0))))
           ([color=BLUE]if[/color] ([color=BLUE]setq[/color] lst (LM:3PCircle p1 p2 ([color=BLUE]trans[/color] ([color=BLUE]cadr[/color] gr) 1 0)))
               ([color=BLUE]entmod[/color] ([color=BLUE]append[/color] cir ([color=BLUE]mapcar[/color] '[color=BLUE]cons[/color] '(10 40) lst)))
           )
       )
   )
   ([color=BLUE]princ[/color])
)

 

Finally, a 3-Point 'PolyArc':

 

[color=GREEN];; 3-Point PolyArc[/color]

([color=BLUE]defun[/color] c:3PPolyArc ( [color=BLUE]/[/color] p1 p2 p3 lst )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] p1  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color]))
           ([color=BLUE]setq[/color] p2  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 2nd Point: "[/color] p1))
           ([color=BLUE]setq[/color] p3  ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 3rd Point: "[/color] p2))
           ([color=BLUE]setq[/color] lst (LM:3PArc  ([color=BLUE]trans[/color] p1 1 0) ([color=BLUE]trans[/color] p2 1 0)  ([color=BLUE]trans[/color] p3 1 0)))
           ([color=BLUE]setq[/color] lst ([color=BLUE]apply[/color] 'LM:Arc->Bulge lst))
       )
       ([color=BLUE]entmake[/color]
           ([color=BLUE]list[/color]
              '(0 . [color=MAROON]"LWPOLYLINE"[/color])
              '(100 . [color=MAROON]"AcDbEntity"[/color])
              '(100 . [color=MAROON]"AcDbPolyline"[/color])
              '(90 . 2)
              '(70 . 0)
               ([color=BLUE]cons[/color] 10 ([color=BLUE]car[/color]   lst))
               ([color=BLUE]cons[/color] 42 ([color=BLUE]caddr[/color] lst))
               ([color=BLUE]cons[/color] 10 ([color=BLUE]cadr[/color]  lst))
           )
       )
   )
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Arc to Bulge  -  Lee Mac 2011[/color]
[color=GREEN];; cen  - Centre[/color]
[color=GREEN];; ang1 - Start Angle[/color]
[color=GREEN];; ang2 - End Angle[/color]
[color=GREEN];; rad  - Radius[/color]
[color=GREEN];; Returns: (<vertex> <vertex> <bulge>)[/color]

([color=BLUE]defun[/color] LM:Arc->Bulge ( cen ang1 ang2 rad )
   ([color=BLUE]list[/color]
       ([color=BLUE]polar[/color] cen ang1 rad)
       ([color=BLUE]polar[/color] cen ang2 rad)
       ( ([color=BLUE]lambda[/color] ( a ) ([color=BLUE]/[/color]  ([color=BLUE]sin[/color] a) ([color=BLUE]cos[/color] a)))  ([color=BLUE]/[/color] ([color=BLUE]rem[/color] ([color=BLUE]+[/color]  [color=BLUE]pi[/color] [color=BLUE]pi[/color] ([color=BLUE]-[/color]  ang2 ang1)) ([color=BLUE]+[/color] [color=BLUE]pi[/color]  [color=BLUE]pi[/color])) 4.))
   )
)

 

Arc->Bulge from my set of Bulge Conversion Functions.

Edited by Lee Mac
Updated functions, added 3PPolyArc
Link to comment
Share on other sites

Use the program below to create the ENTMAKE of what is drawn.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:CRIAENTMAKE ()
(SETQ ARQUIVO "C:\\$ENTMAKE.TXT")
(SETQ ARQ     (OPEN ARQUIVO "w"))
;
;;;CRIA BLOCOS...
;
(WRITE-LINE "(SETQ MBLOCO \"NOMEDOBLOCO\")" ARQ)
(WRITE-LINE "(IF (AND (NOT (FINDFILE (STRCAT MBLOCO \".DWG\"))) (NOT (TBLSEARCH \"BLOCK\" MBLOCO) ))" ARQ)
(WRITE-LINE "    (PROGN" ARQ) 
(WRITE-LINE "    (ENTMAKE (list (cons 0 \"BLOCK\") (cons 2 MBLOCO) (cons 8 \"0\") (cons 10 (list 0 0 0)) (cons 70 2) ) ) ;(CONS 70 2)=BLOCO COM ATRIBUTOS" ARQ)
(SETQ ENT (ENTNEXT))
(WHILE ENT
(SETQ LIS (ENTGET ENT))
(PRINC "\n" ARQ)
(PRINC "    (ENTMAKE (LIST " ARQ)
(SETQ NN  0)
(REPEAT (LENGTH LIS)
  (SETQ CCC  (NTH NN LIS))
  (IF (AND (/= (CAR CCC) -1) (/= (CAR CCC) 5) (/= (CAR CCC) 330) (/= (CAR CCC) 410) )
      (PROGN
      (PRINC " '" ARQ)
      (PRIN1 CCC  ARQ)
      )
  )
  (SETQ NN (+ NN 1))
)
(PRINC      " )" ARQ)
(PRINC      " )" ARQ) 
(SETQ  ENT (ENTNEXT  ENT))
)
(WRITE-LINE "    (ENTMAKE (list (cons 0 \"ENDBLK\")))" ARQ)
(WRITE-LINE "    )" ARQ)
(WRITE-LINE ")    " ARQ)
(WRITE-LINE ";    " ARQ)
(CLOSE ARQ)
(ALERT "*** BLOCO CRIADO COM SUCESSO! ***")
(COMMAND "NOTEPAD" ARQUIVO)
;
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(PROMPT "\n==> CRIAENTMAKE <==")
(PRINC)

 

OK?

Link to comment
Share on other sites

Thanks Lee, i'll try to solve my problem with yours function, and i think it'll be okey.

@Felixjm : thank u, i'm finding the solution with some of calculate geometry ^^

Thank all for help, i love all of you :)

Link to comment
Share on other sites

Ketxu

After you made the block, probable you will think to make it dynamic. Also the same block could contain the front, the top and the side view of the nut -and of course a visibility state to select the desired one.

Link to comment
Share on other sites

Ketxu

After you made the block, probable you will think to make it dynamic. Also the same block could contain the front, the top and the side view of the nut -and of course a visibility state to select the desired one.

@fuccaro : I see, i will draw a block by hand, but first thing, i want to make it by some of code entmake ^^

@Lee : I will apply your code to make arc now , but, if you already have solution for make same Pline through 3 Point, let me know please ^^, or i will try to find out in the near future ^^ Thank you again

Link to comment
Share on other sites

@Lee : I will apply your code to make arc now , but, if you already have solution for make same Pline through 3 Point, let me know please ^^, or i will try to find out in the near future ^^ Thank you again

 

Ketxu,

 

You could use the 'Arc->Bulge' function from my Bulge Conversion functions to convert the return of the '3PArc' function to units suitable for use with LWPolylines.

 

Shame I've not been consistent with the order of my arguments/returns. I fail. Facepalm.gif

Link to comment
Share on other sites

ketxu, see if this drawing is OK, and if it is use this code to make lisp for entmakex drawn objects :

 

(defun c:drawit ( / ss ssh acsel ssn k ent entl entll entlll f)
(vl-load-com)
(if (setq ssh (ssget "X" '((0 . "HATCH"))))
(progn
(vlax-for obj (setq acsel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
(vla-put-associativehatch obj :vlax-false)
)
(vla-delete acsel)
)) 
(setq ss (ssget "X"))
(setq ssn (sslength ss))
(setq f (open "C:/mklist.lsp" "w"))
(setq k -1)
(repeat ssn
(setq k (1+ k))
(setq ent (ssname ss k))
(setq entl (entget ent))
(foreach x entl
(if (and (/= (cdr (assoc 0 entl)) "HATCH") (/= (car x) -1) (/= (car x) 1) (/= (car x) 2) (/= (car x) 5) (/= (car x)  (/= (car x) 102) (/= (car x) 330) (/= (car x) 360))
(setq entll (cons x entll))
)
(if (and (= (cdr (assoc 0 entl)) "HATCH") (/= (car x) -1) (/= (car x) 5) (/= (car x)  (/= (car x) 102) (/= (car x) 330) (/= (car x) 360))
(setq entll (cons x entll))
)
)
(setq entll (reverse entll))
(setq entll (list (list 'quote entll)))
(setq entlll (cons 'entmakex entll))
(print entlll f)
(setq entll nil)
(setq entlll nil)
)
(close f)
(princ)
)

See attached *.dwg...

Regards, M.R.

Drawing-ketxu.dwg

Model-ketxu.dwg

Edited by marko_ribar
dwg corrected - added model
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...