insert cont. Block

insert cont. Block

k005
Advisor Advisor
758 Views
7 Replies
Message 1 of 8

insert cont. Block

k005
Advisor
Advisor

 

 

 

 

 

 

(defun c:mim (/ bry)
(setvar "cmdecho" 0)
(setvar "OSMODE" 1)
  
(if (= ant2 nil)(setq ant2 10))
(setq ant2_t (getreal (strcat "\nÖlçek giriniz   <" (rtos ant2 2 2)"> : ")))
(if (= ant2_t nil)(setq ant2_t ant2))
(setq ant2 ant2_t)
(setq bry(getpoint "\nBu noktaya: "))
(command "-insert" "mim01" "scale" ant2 bry  "")
(setvar "cmdecho" 1)
(setvar "OSMODE" 0)
(princ)
)

 

 

 

 

 

 

D:\Blocks\    «--- Supported...

xxxx01.dwg

xxxx02.dwg

xxxx03.dwg

xxxx04.dwg

 

Hello to everyone

I have blocks in this order in the folder I specified.

When I run the mim command; How can I call the block with the last numeric value?

 

(command "-insert" "xxxx04" "scale" ant2 bry "")

 

0 Likes
Accepted solutions (1)
759 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

If all the files in that directory are named the same way except for the numerical ending, try this:

 

(command "-insert"

  (last (vl-sort (vl-directory-files "D:/Blocks" "*.dwg" 1) '<))

  "scale" ant2 bry ""

)

Kent Cooper, AIA
Message 3 of 8

k005
Advisor
Advisor

I added the code. but it doesn't get a block.

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

What does this by itself return?

 

(vl-sort (vl-directory-files "D:/Blocks" "*.dwg" 1) '<)

Kent Cooper, AIA
Message 5 of 8

k005
Advisor
Advisor

@Kent1Cooper  sorry I made a mistake... The code is working.
Thank you so much.

0 Likes
Message 6 of 8

k005
Advisor
Advisor

(vl-sort (vl-directory-files "D:/Blocks" "*.dwg" 1) '<)

 

 

Blocks = is Fixed...

 

"D:/Blocks"

 

How can I make it find this path automatically?

well ;

Let him look in the AutoCAD support folders - and find it himself.. how can we do this?

0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

OPTIONS command dialog box:


Kent1Cooper_0-1642442526897.png

 

Kent Cooper, AIA
Message 8 of 8

k005
Advisor
Advisor

I know the situation in this part.

 

I wanted to say, can we have the folders here look through the code?

 

 

So if it could be...

Not important. I can edit lisp., or support folders as you mentioned...

0 Likes