Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert Block with browser window pre-set path

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
JCprog
1947 Views, 13 Replies

Insert Block with browser window pre-set path

Hello EveryoneSmiley Happy

 

I've been searching for a lisp routine that can make browsing and inserting a block more easy. Using the toolpalette-route is great and "cute" but gruesome to update with thousands of blocks, so many categories and annual changing versions (....well u get the point).

 

I just need this to be fairly simple and T-squared-straight-forward.  Upon typing insert i want to have a windows browsing window instead of the insert dialogue box which ask Insertion point, scale & rotation----I need to go straight to "browse" with a pre-set path. after that choose and select the desired block double-click it and then insert. I found this code below at Lazy drafter I just have no idea how to go about inserting a block. Please help! Thanks in advanceSmiley Happy

 

 

(startapp "explorer" (strcat "/n,/e," "N:\\CAD\\BLOCKS")) 

 

 

 

13 REPLIES 13
Message 2 of 14
hmsilva
in reply to: JCprog

The Getfiled function may be useful...

 

As a demo:

(Getfiled "Select Drawing File" "N:\\CAD\\BLOCKS\\" "Dwg" 8)

 

HTH

Henrique

EESignature

Message 3 of 14
Shneuph
in reply to: JCprog

What about drag and drop from explorer into the drawing window?  That inserts as a block.

Drag file from explorer to model space drawing window>Pick insertion point>hit space (or enter) 3 times.  That inserts for me fairly easily.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 4 of 14
JCprog
in reply to: hmsilva

Thanks for the reply Henrique. How can I use this function with inserting block?
Message 5 of 14
JCprog
in reply to: Shneuph

explorer drag & drop simple but most of our users will not conform to it. I need it to be at least user-friendly to say the least 😉
Message 6 of 14
hmsilva
in reply to: JCprog

Try

 

(defun c:demo (/ blk)
  (if (setq blk (getfiled "Select Drawing File" "N:\\CAD\\BLOCKS\\" "Dwg" 8))
    (command "_.insert" blk "_S" 1 pause 0)
  )
  (princ)
)

HTH

Henrique

EESignature

Message 7 of 14
JCprog
in reply to: hmsilva

It worked!!!!Smiley Very Happy

Message 8 of 14
JCprog
in reply to: hmsilva

oh wait.....I take it back! it does work perfectly! it's the blocks that are not created properly is the problem. Thanks Henrique!!!! Is there a way to make the browsing window a lil bigger? setting a its window size?
Message 9 of 14
hmsilva
in reply to: JCprog


@JCprog wrote:
It worked on first shot but gives an error if I try to insert another block:
Command: DEMO
Block xxxx references itself
*Invalid*

It should not...

I can't reproduce that behavior...

 

Henrique

EESignature

Message 10 of 14
JCprog
in reply to: hmsilva

It did work the way it should be. It was just the blocks that werent created properly is the problem. Thanks for code Henrique!!!! Can I make that window a lil bigger? Maybe set its size?
Message 11 of 14
hmsilva
in reply to: JCprog


@JCprog wrote:
It did work the way it should be. It was just the blocks that werent created properly is the problem. Thanks for code Henrique!!!! Can I make that window a lil bigger? Maybe set its size?

You're welcome, JCprog!

 

I think it will not be possible to make the window bigger...

 

Henrique

EESignature

Message 12 of 14
3wood
in reply to: JCprog

You can use DesignCentre. Ctrl+2, browse to your folder, then right-click the block, select "Insert as block..." from the short-cut menu, or just drag it to the drawing.

 

Message 13 of 14
patilhdipak
in reply to: hmsilva

if we want  insert multiple blocks to use in the file and if we select only one block  can we find remaining blocks on that path without going to that path again and again which is get form getfiled function.

Message 14 of 14
dlanorh
in reply to: patilhdipak

Use THIS

to get the file names returned as a list e.g.

(setq blk_lst (LM:getfiles "Select Blocks" "" "dwg")

the above will allow you to browse to a directory then choose drawings in the left panel and add them to the right panel

pressing OK returns a list of drawings complete with path from the right panel.

 

Then

 

(setq pt (getpoint "\nselect insertion point for blocks))
(foreach blk blk_lst (vl-cmdf "-insert" blk pt 1 0) )

This should insert every selected drawing as a  block into the drawing at the selected point.

 

Just make sure that

1. if the drawing contains a block, that the drawing is not the same name as the block it contains

2. or if it is, that the block within the drawing is exploded.

 

In case 1 just explode all the inserted drawings to leave yourself with the blocks, then erase

In case 2 just erase

 

I am not one of the robots you're looking for

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost