Jump to content

insert block and scale


rookie37

Recommended Posts

I need a lisp routine that will;

Prompt me for the ‘Y’ scale (0.379 in this case)

Prompt me for the block name (rot 3 in this case)

Prompt me for the size (582 in this case)

 

Insert block rot 3 at scale x = 1 y = .379 at position 0,0

 

Scale block 582

Link to comment
Share on other sites

Is this a request for someone to write it for you... or just a statement that you need one?

Post your attempt at the code and I'm sure some here will help.

Link to comment
Share on other sites

Sorry. I guess I was lazy.

 

 

 

(defun C:test ()
(setq echo (getvar "CMDECHO"))
(setq OS (GETVAR "OSMODE"))
(SETVAR "OSMODE" 0)
(setvar "CMDECHO" 0)
(setq blokname (getname "\nEnter block name:  "))   **rot 3
(setq yvalue (getname "\nEnter Y value:  "))
(setq oall (getname "\nEnter overall dimension:  "))





(command "-insert" blokname "" y "" yvalue "" 0,0 "" "")
(command "scale""l"" oall "" "")




(setvar "CMDECHO" echo)
(SETVAR "OSMODE" OS)
(PROGN)
)

Link to comment
Share on other sites

I'm not quite sure why you need a lisp routine... just follow the prompts from the insert (or -insert) command.

Link to comment
Share on other sites

(setq blokname (getname "\nEnter block name:  "))

 

getname was only a guess. What is the correct syntax?

Link to comment
Share on other sites

(setq blokname (getname "\nEnter block name:  "))

 

getname was only a guess. What is the correct syntax?

 

That would be:

(setq blokname (getstring T "\nEnter block name:  "))

 

1. watch it: you use bloKname and probably mean bloCKname so do not get confused by this. Better would be to use the right word straight off.

2. Getstring allows to put a word in variable.

3. The "T" is to allow a "space" in the stringname like "This is a test".

 

But ...

 

I need a lisp routine that will;

Prompt me for the ‘Y’ scale (0.379 in this case)

Okay...

 

Prompt me for the block name (rot 3 in this case)

Yep...

 

Prompt me for the size (582 in this case)

:huh:

 

Insert block rot 3 at scale x = 1 y = .379 at position 0,0

Scale block 582

 

Strange way of doing stuff but okay:

 

 
; MarcoW / 27-05-2010
(defun C:Test (/ 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:  ")
ScaleY   (getreal "\nEnter Y scale value:  ")
ScaleXY   (getreal "\nEnter overall scaling:  ")
Rot   (getreal "Specify rotation angle of the block :  ")
 )
 (vl-cmdf "._insert" BlockName InsPt ScaleX ScaleY Rot)
 (vl-cmdf "._scale" "_L" "" InsPt ScaleXY)

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

 

Hope it helps!

Link to comment
Share on other sites

Thank you very much!!!!

 

And you're right. It is a strange way of doing stuff.

 

I'm not that good at programming and only modify the modified programs that have already been modified

 

How do I update it to pick a block from a certain directory? (one that isn't already in the drawing or in the path?

Link to comment
Share on other sites

Thank you very much!!!!

You are welcome. Nice to do something back after all the time people helping me out.

 

I'm not that good at programming and only modify the modified programs that have already been modified

THen keep on modifying :)

 

How do I update it to pick a block from a certain directory? (one that isn't already in the drawing or in the path?

You should either build in a *.dcl (dialog box) that gives you the option to browse to the file. Or you should manually enter the right location.... Both are some work and some mouse clicks....

 

Why not approach it totally different with macro's in a toolpalette or menu (or even toolbar...) Are you familiar with that?

I am running out of time now so if I should help you you will need to wait a little..

 

CU.

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