Jump to content

Insert block, add circle, exlode, create block


rookie37

Recommended Posts

I need to insert a block

 

Prompt me for the block name

Prompt me for the y scale of the block

prompt me for the overall size of the block

insert the block

add the circles

explode the block

create a new block that includes the circles

 

please help

 

(defun C:fp (/ BlockName CmdEchoOld InsPt OsmodeOld Rot ScaleX ScaleXY
       ScaleY)
 (vl-load-com)
 (setq CmdEchoOld (getvar "CMDECHO")
OsmodeOld  (getvar "OSMODE")
 )
 (setvar "CMDECHO" 0)
 (SETVAR "OSMODE" 0)
 (setq BlockName (getstring T "\nEnter block name:  ")
InsPt   (getpoint "Specify insertion point:  ")
  ScaleX   (getreal "\nEnter X scale value:  ")  ;;; no need for this line as y always = 1
        (setq fp(getdist"\nEnter the focal point: "))
            (setq ns(getdist"\nEnter the ns point: "))
                ScaleY   (getreal "\nEnter Y scale value:  ")
                ScaleXY   (getreal "\nEnter overall scaling:  ")
      Rot   (getreal "Specify rotation angle of the block :  ");;; no need for this line as the rotation is always 0
 )
 (vl-cmdf "._insert" BlockName InsPt ""ScaleY Rot)
 (vl-cmdf "._scale" "_L" "" InsPt ScaleXY)

(setq fp3(list(-(car inspt)(fp))((cadr inspt))))
(setq fp4(list(+(car inspt)(fps))(cadr inspt))))
(setq ns1(list(car inspt)))(-(cadr inspt)(ns))))
(setq ns2(list(car inspt)(ns))(+(cadr inspt)(ns))))
(COMMAND "circle" fp3 2)
(COMMAND "circle" fp4 2)
(COMMAND "circle" ns1 2)
(COMMAND "circle" ns2 2) 

 (setvar "CMDECHO" CmdEchoOld)
 (setvar "OSMODE" OsmodeOld)
(princ)
)
(princ)

macro.JPG

Link to comment
Share on other sites

I don't know if it's practical to use a macro to make a block. I don't mean to hit this forum with a big ask. I can easily make this into a block.

 

The BIG help would be to draw the 4 circles.

 

the code I provided was pasted together from 3 different macros. This is why it is so confusing. I didn't realize how bad it was until now when I saw

 

(setq fp3(list(-(car inspt)(fp))((cadr inspt))))

Link to comment
Share on other sites

yep, could you send me the dwg with the block you use?:)

 

also include the circels you want to insert on wich place include the radius;)

Does the lines crosses the little circle need to be trimmed?:)

 

Regards MR

Link to comment
Share on other sites

The block is the circle. I insert it, scale the y (.5 in this case)

and then scale the block (5000 in this case)

Add the circles (fp 3 and 4 are the focal points of the ellipse)

and add the ns points

 

the line going through ns2 does not need to be trimmed.

The dia of the 4 circles are 0.04 * the overall size (200 in this case)

sdial.dwg

Link to comment
Share on other sites

I'm trying to draw the 4 circles as shown in the drawing above but keep getting an error

 

 

(defun c:fp2 ()
(graphscr)


(setq fp(getdist"\nEnter focal point: "))
(setq ns(getdist"\nEnter ns point: "))
(setq inspt(getpoint"\nPlace to add to the block :"))




(setq p1(list(-(car inspt)(fp))(cadr inspt)))
(setq p2(list(+(car inspt)(fp))(cadr inspt)))
(setq p3(list (car inspt))(+(cadr inspt)ns)))
(setq p4(list (car inspt))(-(cadr inspt)ns)))

   

(COMMAND "circle" p1 10) 
(COMMAND "circle" p2 10)
(COMMAND "circle" p3 10) 
(COMMAND "circle" p4 10) 








)


Link to comment
Share on other sites

well you can add the circles lick in my code below,...

 

(defun c:fp2 ()
 ;Made by rooky37
 ;Autocad The Netherlands 
 ;Copyright © MR. CAD Mitchell Rodhouse
 ;;;;;;Thankfully to MR. CAD -Mitchell Rodhouse
 ;define the function
 
(graphscr)
 ;*
 ;Save System Variables
 (setq oldsnap (getvar "osmode"))
 
 ;save snap settings
 (setq oldblipmode (getvar "blipmode"))
 ;save blipmode setting
 (setvar "cmdecho" 1)
 (setvar "INSUNITS" 4)
 ;*
 ;Switch OFF system Variables
 (setvar "osmode" 0)
 ;Switch OFF snap
 (setvar "blipmode" 0)
 ;Switch OFF Blipmode
 ;*
 
 ;get User Inputs

 (setq fp (getdist"\nEnter focal point: "))
 (setq ns (getdist"\nEnter ns point: "))
 
 ;*
 ;Get Insertion Point
 
 (setq inspt(getpoint"\nPlace to add to the block :"))
 (setvar "osmode" 32)
 ;switch ON snap
 (setvar "osmode" 0)
 ;switch OFF snap
 ;*
 ;Start of Polar Calculations

 (setq p1 (polar inspt (dtr -90.0) fp))
 (setq p2 (polar inspt (dtr 90.0) fp))
 (setq p3 (polar inspt (dtr 180.0) ns))
 (setq p4 (polar inspt (dtr 0.0) ns))

 ;End of the Polar calculations by MR. CAD - MITCHELL RODHOUSE
 ;*
 ;Start Command Function
   
 (COMMAND "circle" p1 200
     "circle" p2 200
     "circle" p3 200 
     "circle" p4 200
   
 ) ;End command
;End of Commands made by MR. CAD - MITCHELL RODHOUSE
 (setvar "osmode" 32)
 ;switch ON snap
 
 ;*
 ;Reset System Variable
 (setvar "osmode" oldsnap)
 ;Reset snap
 (setvar "blipmode" oldblipmode)
 ;Reset blipmode
 (setvar "cmdecho" 0)
 (princ "Copyright © - Written by MR. CAD")
 (setvar "cmdecho" 1)
 
 ;*
 (princ)
 ;finish cleanly
 
 ) ;end of defun
;*
;This function converts Degrees to Radians.
(defun dtr (x)
 ;define degrees to radians function
 (* pi (/ x 180.0))
 ;divide the angle by 180 then
 ;multiply the result by the constant PI
) ;End of function
;*
(princ) ;load cleanly

;*
;;HOPE THIS LISP WILL BE FUNCTIONAL FOR THE USER
;;MADE BY MR. CAD - MITCHELL RODHOUSE
;;END LISP

 

I can make an block with references from this point also and also include an ellipse by given places.. also can load your block on an given position than explode it.... hmm I am going to try for you... don't you want to insert the diameter of the circels?

 

Regards MR

Link to comment
Share on other sites

Thank you mitchellrodhous!

 

Yes I would like the dia of the 4 circles to be 0.04 * the overall size but I didn't now how to do that

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