Inserting blocks with lisp

I am using the following code to insert blocks because it allows me to prompt for the rotation angle.
(princ "\nSelect insertion point for block: ")
(command "-insert" some_block "s" (getvar "dimscale") pause nil) (princ "\nRotation angle: ") (command "-insert" some_block "s" (getvar "dimscale") (getvar "lastpoint") pause)
The problem is that when there is are running osnaps and an osnap is manually selected the (getvar "lastpoint") returns the point picked by the running osnaps. For example with a running osnap of endpoint and selecting the midpoint of a line the (getvar "lastpoint") returns the endpoint. Is there another way that I should be doing this? Thanks Cliff
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cliff Davis wrote:

Have you looked into using ENTMAKE? If there are no attributes, it should be relatively simple. ENTMAKE allows much more control. It would look something like this:
(initget 1) (setq ipt (getpoint "\nInsertion point: ")) (initget 1) (setq rpt (getpoint ipt "\nPick orientation point: ")) (setq insang (angle ipt rpt)) (entmake (list '(0 . "INSERT") (cons 2 "BlockNameHere") (cons 10 ipt) (cons 41 5.0) ;X scale (cons 42 5.0) ;Y scale (cons 43 5.0) ;Z scale (cons 50 insang) ));list, entmake (entmake (list '(0 . "SEQEND")))
Repost if you need some explanation.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I have in the past, but it doesn't allow a graphic representation of the block while inserting. Thanks Cliff

point
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cliff Davis wrote:

How about this:
(setq oldos (getvar "OSMODE")) (setvar "OSMODE" 0) ;insertion here (setvar "OSMODE" oldos)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Almost forgot another way I've done similar things.........Insert the block, then issue the "CHANGE" command, pausing for the user selection.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

this works because it snaps to the over ride osnap and processes that result to the running mode.
like, you want the midpoint, you select the midpoint and THEN autocad takes that point and applies the endpoint osnap to that, ending up with the endpoint.
right?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Here is a way of doing it also. This is a slight modification of the way I do it. It is a scaled insert command.
(defun c:scldinsrt () (setq insblknm (getstring "\nEnter Block Name...")) (setq sc (getvar "dimscale")) (command "-insert" insblknm "scale" sc pause) (princ) ) This works great for me. I can use running osnaps or manual snaps. Good Luck -- Darek D. Watson CAD Manager

prompt for the rotation angle.

"lastpoint") pause)

manually selected the (getvar "lastpoint") returns the point

endpoint and selecting the midpoint of a line the (getvar

doing this?

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.