What could go Wrong?

What could go Wrong?

pmercader
Advocate Advocate
1,019 Views
9 Replies
Message 1 of 10

What could go Wrong?

pmercader
Advocate
Advocate

Hello,

 

With the help of people here I managed to create a simple lisp to grab a block from an external .dwg file (using Lee Mac's Steal) and insert it at the current drawing. Currently for testing purposes I have one lisp that has 10 separate insert functions for 10 unique blocks. Now looking ahead, I am thinking, once I have 1000 separate insert functions in there to insert 1000 unique blocks, could that cause Autocad to load longer during startup?  If it does, what are your suggested solutions. Also, I think that would be a challenge to manage. 

 

 

Thanks, 

0 Likes
Accepted solutions (1)
1,020 Views
9 Replies
Replies (9)
Message 2 of 10

Shneuph
Collaborator
Collaborator

i don't think you've given enough information for anyone to help you come up with a solution.  Can you post one of the 10 functions that you are using and a better description of what the workflow is?

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 10

pmercader
Advocate
Advocate

Basically its this lisp but repeated multiple times.

 

(defun c:test1 (/ cmd oldlayer pt)
(Steal "../Source/Source.dwg" '(("Blocks" ("test1"))))
(command "_.dragmode" "_Auto")
(setq cmd (getvar 'CMDECHO)) (setvar "CMDECHO" 0)
(setq oldlayer (getvar "CLAYER"))
(command "-layer" "make" "0" "")
(setq pt (getpoint "\nSpecify insertion point: "))
(command "-insert" "test1" pt "" "")
(setvar 'CMDECHO cmd);
(setvar "CLAYER" oldlayer)
(princ)
)

 

0 Likes
Message 4 of 10

Shneuph
Collaborator
Collaborator

...and the only thing that changes is "test1" to other block names?

 

Is the sole purpose of doing it with the lisp to put the blocks on layer 0 and only ask for the insertion point instead of scale and rotation?  I don't think layer 0 can be purged so there is no need to 'make' it right?

 

I would ask why Toolpalettes or the DesignCenter would not work?

Not to be argumentative or say your way is wrong, just to see what you're trying to accomplish exactly that these will not suffice.  Or, what is the advantage of doing it with this lisp?

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 5 of 10

dlanorh
Advisor
Advisor
Why not do it once and save the drawing as a template.

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

0 Likes
Message 6 of 10

dgorsman
Consultant
Consultant

As I am fond of saying: change the data, not the code.  In other words create a function that does the same thing but pass in different values through an argument. 

 

You'll still need individual command line functions for each command you want.  There shouldn't be thousands of them though.  You should evaluate what gets used where, how often, and other work flow considerations.  For at least some of them there will be a single command call which prompts the user to make some choices.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 7 of 10

pmercader
Advocate
Advocate
Accepted solution

With the help of great people in this community I have solved this problem by having the lisp ask for an input and the use that input to find the block instead of having a lisp for every block to be inserted.

 

See solution here.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/use-user-input-as-value/m-p/9063638#...

0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

Building a slide library menu interface is very easy and its visual, plus you can add control when you do say a insert like what layer to use. If you use notepad you can make a menu.

 

 

Message 9 of 10

pmercader
Advocate
Advocate

Wouldn't this work only if the blocks are stored in one .dwg file? The thing is, the blocks are stored in multiple files so I had to edit the lisp to look into multiple files until it finds the block. But this pretty cool. How'd you do that? DCL? I'd like to learn more about dialog boxes.

0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

I would look seriously at exporting the blocks to a library directory. If you use wblock it will make real small DWG's. Have a look at this has some explanations.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/where-to-start-cui-menus-multiple-se...

0 Likes