Jump to content
Jim Clayton

Add "Insert Dynamic Block" to Existing Lisp

Recommended Posts

Jim Clayton

Hello.  I'm in the process of building a Lisp/DCL.  I want to add a few steps where you can select an insertion point and insert a Dynamic Block at that point.  Is there a quick and  easy way of going about this?  The Lisp/DCL are both still in the beginning stages and VERY much under construction.  The end product that I'm trying to build though looks like a vertical piece of pipe with a Dynamic Block on Top and Bottom and two Dynamic Blocks coming off of the side (spaced an equal distance apart).  Would greatly appreciate any help.  Tks.

Share this post


Link to post
Share on other sites
jonathann3891

There are multiple ways to accomplish this.

 

(defun c:somefunc (/ ds)
(setq ds (getvar 'dimscale))

(command "insert" "block_name" "_scale" ds "_rotate" 0 pause)
  (princ)
  )

 

Edited by jonathann3891

Share this post


Link to post
Share on other sites
Jonathan Handojo

As jonathann3891 says, there are many ways to insert a block. I normally do it by ActiveX ways, since "command" normally takes time to execute. For example:

 

(setq acadobj (vlax-get-acad-object)
      adoc (vla-get-ActiveDocument acadobj)
      msp (vla-get-ModelSpace adoc)
      block_name (getstring T "\nSpecify block name: ")
      insertpt (getpoint "\nSpecify insertion point: ")
      scale_x 1
      scale_y 1
      scale_z 1
      rotation 0 ; in radians
      your_block (vla-InsertBlock msp (apply 'vlax-3D-Point insertpt) block_name scale_x scale_y scale_z rotation))

but will fail if insertpt returns nil (happens when you press Enter on prompt)

 

If you have a list of hundreds of blocks and points for each block, you can always do:

 

(setq blocks (mapcar
	       '(lambda (x y)
		  (vla-InsertBlock msp (apply 'vlax-3D-point y) x scale_x scale_y scale_z rotation))
	       block_name insertpt))

 

 

My preference of style is constructing a dotted pair for each block and point, them put them in a list. 

Share this post


Link to post
Share on other sites
BIGAL

Have a look on Lee-mac.com for dynamic block routines for updating from a lisp. Just insert as per other post.

 

Your welcome to use Multi getvals.lsp its a library routine for multiple input via a dcl. You can have from 1 to say around 15 entries. 

 

Multi GETVALS.lsp

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
Jim Clayton

Thank you both.  I'll give these a shot.  I feel like I might be over-complicating this and making it more difficult than it needs to be so i'm going to step back and re-organize this first.  Thanks again for the help.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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