Jump to content

Insert Dynamic Block and set variables


flowerrobot

Recommended Posts

I have searched and could only find vba code for this, and i kno nothing of the stupied simple code, but any way

 

I am trying to insert a dynamic block

with the a paramaters included

 

(defun c:ip()
(setq oldlayer (getvar "-.layer"))   
(setvar "cmdecho" 0)
(setq sc (getvar "dimscale"))
(SETQ LA (GETVAR "OSMODE"))
(COMMAND "LAYER" "S" "DIM" "")
(command "osmode" 5)
(setq pt1(getpoint "\nSELECT FIRST POINT : "))
(setq pt2(getpoint "\nSELECT SECOND POINT : "))
(SETQ XA ((CAR PT1)-(CAR PT2))) ; not sure if these are correct
(SETQ YA (CAR PT1)-(CAR PT2))
(SETQ LG (SQROOT(XA)^2+(YA)^2))
(SETQ AG (SIN^-1 (XA/YA)))
(COMMAND "INSERT" "ITA" PT1 SC SC 0)

I WANT TO PLACE IMPUT IN THIS BIT HERE
LENGTH = LG
ANGLE = AG
(COMMAND "LAYER" "S" OLDLAYER "")
(command "osmode" la)
(Setvar cmdecho 1)
(princ)
)

Link to comment
Share on other sites

This'll get you started - I haven't got the time to be thinking too much :P

 

(defun c:ip (/ oldlayer oldcmd sc oldsnap pt1 pt2 lg ag)
   (setq oldlayer (getvar "clayer"))   
   (setq oldcmd (getvar "cmdecho"))
   (if (/= (setq sc1 (getvar "dimscale")) 0.0)
   (setq sc sc1)
   (setq sc 1.0)) ; end if
   (setq oldosnap (getvar "osmode"))
   (if (not (tblsearch "layer" "DIM"))
       (command "-layer" "m" "DIM" "")
       (setvar "clayer" "DIM")
   ) ; end if
   (command "osmode" 5)
   (if     
       (and
            (setq pt1 (getpoint "\nSELECT FIRST POINT : "))
            (setq pt2 (getpoint "\nSELECT SECOND POINT : "))
       ) ; end and
       (progn
            (setq lg (distance pt1 pt2))
            (setq ag (angle pt1 pt2))
            (command "insert" "ITA" pt1 sc sc 0)

; I WANT TO PLACE IMPUT IN THIS BIT HERE
; LENGTH = LG
; ANGLE = AG

        ) ; end progn
     ) ; end if
    (setvar "clayer" oldlayer)
    (setvar "osmode" oldsnap)
    (setvar "cmdecho" oldcmd)
    (princ)
)

Link to comment
Share on other sites

Cheers, must say you are very conisise with you layouts arnt you, some thing im quite lacking in.

 

good to kno distance and angle is that easy to create,

 

just need to be able to place that info into the dynamic blocks properites

Link to comment
Share on other sites

Sorry i dnt relise you had replied to me their,

and i dnt want to high jack his thread,

and it also gives an easyer search from some one eles :D

cheers

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