Jump to content

Recommended Posts

Posted

Hi Everyone,

I have a three lisp to create layouts automatically for three different sheet size. (A1,A2 & A3). Right now I'm running the lisp separately for required sheet size. Instead of that can we run the lisp based on block name which i inserted for layout creation.

For Ex. If i inserted A2 block, then lisp will check the block availability (A1,A2 & A3) A2 is available now...so lisp for creating A2 sheet should be run.

 

Thanks in advance.

Posted

Hi Tharwat,

Using that we can run the lisp from the options..but in that case we need to select the lisp based on inserted block.

Is there any other way to run the lisp automatically by available block name.

 

 

Thanks.

Posted

What I meant with my previous reply is that you can have one program asks the user about the block name then insert it if that block name is existed into the same drawing otherwise an alert message to inform the user is that the block name is not available.

 

(initget "A1 A2 A3")
(setq blk (getkword "\nSpecify block name to insert [A1,A2,A3:"))
(if (tblsearch "BLOCK" blk)
   ;;; then your stuff here to insert the desire block name once its available in drawing.
   ;; else alert a message to user.
  )

 

Posted

Thanks for the Explanation,

I have checked that but i don't know exactly that how to modify that. could you please help me on this.

(defun c:123(/)
 (initget "A1 A2 A3")
(setq blk (getkword "\nSpecify block name to insert [A1,A2,A3]:"))
(if (tblsearch "BLOCK" blk)
 (C:A1)
  (C:A2)
  (C:A3)
   ;;; then your stuff here to insert the desire block name once its available in drawing.
   ;; else alert a message to user.
  ;(alert "Hi")
  )
  )


(defun c:A1 (/)
  (alert "A1 Here")
  )
(defun c:A2 (/)
  (alert "A2 Here")
  )

(defun c:A3 (/)
  (alert "A3 Here")
  )

 

Posted

Give this a go and let me know.

(defun c:Test (/ blk)
  (initget "A1 A2 A3")
  (and (setq blk (getkword "\nSpecify block name to insert [A1,A2,A3]:"))
       (or (tblsearch "BLOCK" blk)
           (alert (strcat "Block name < "
                          blk
                          " > was not found in this drawing."
                  )
           )
       )
       (eval (nth (vl-position blk '("A1" "A2" "A3"))
                  '((c:A1) (c:A2) (c:A3))
             )
       )
  )
  (princ)
)

 

Posted (edited)

@Tharwat

I did not read this whole thread but FWIW .. you could shorten up your eval code like so:

(eval (read (strcat "(c:" blk ")")))

 

Edited by ronjonp
Posted

Thanks Ron for your important note. :) 

Although that I recommended the OP just to have these three routines as one but apparently they have their reason to go with one. 

Posted

Thank you so much Ron and Tharwat,

It's working perfectly now.

 

Thanks Again:celebrate:

Posted
9 hours ago, CADZealot said:

Thank you so much Ron and Tharwat,

It's working perfectly now.

 

Thanks Again:celebrate:

Good to hear that. :D 

You're welcome anytime. 

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