TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GUIDO ROOMS on November 25, 2012, 01:47:53 AM
-
Does anyone know a method to load a block definition into the blocks table from a file?
Thanks in advance, as ever.
-
Two ways:
(command "_.-insert" <full
-filename
-of
-block
> nil)
<full-filename-of-block>
1.0
1.0
1.0
0.0
)
)
By using the full filename when inserting the block, the block definition will be reloaded into the drawing.
-
Of course you may also want to erase the insert/reference after the command. You can also make a new blank block definition and then use the CopyFrom method through ObjectDBX, but that would be a whole lot of extra code simply to avoid an erase.
-
Of course you may also want to erase the insert/reference after the command.
This is not required in my example since the Insert command is cancelled (by the presence of the nil) before the reference is inserted but after the definition is loaded into the drawing.
-
Thank you Lee for the reply.
In fact, that's what I've been doing so far.
One can also do it using the .net api, but I was looking for a lisp function to add a block definition directly to the table without inserting and then erasing it (maybe I should have been more clear about that in my first post).
Perhaps Irneb's reply is what I was looking for: the answer is "no", at least there's no straightforward & simple way to do it in lisp.
Thanks to both of you.
Greetings.
-
This is not required in my example since the Insert command is cancelled (by the presence of the nil) before the reference is inserted but after the definition is loaded into the drawing.
True! I'd overlooked that one...
-
I was looking for a lisp function to add a block definition directly to the table without inserting and then erasing it (maybe I should have been more clear about that in my first post).
This is also possible, consider the following example:
(defun c:makeblock
( / bnm doc ins lst sel
) )
)
(princ "\nBlock name invalid or already exists.") )
(/= "" bnm)
(ssget '
((410 .
"Model"))) )
)
bnm
)
)
)
)
)
Or, if you wish to create the block definition from scratch:
(defun c:makeblock
( / bnm
) )
)
(princ "\nBlock name invalid or already exists.") )
bnm
)
10.0
)
)
)
Otherwise, you could also use ObjectDBX and the copyobjects method with an external drawing file.
-
This is not required in my example since the Insert command is cancelled (by the presence of the nil) before the reference is inserted but after the definition is loaded into the drawing.
Ah! Sorry ... yes missed that :-[
-
This is not required in my example since the Insert command is cancelled (by the presence of the nil) before the reference is inserted but after the definition is loaded into the drawing.
Ah! Sorry ... yes missed that :-[
No problem! :-)
-
Otherwise, you could also use ObjectDBX and the copyobjects method with an external drawing file.
Here is a general example of this method:
http://lee-mac.com/steal.html (http://lee-mac.com/steal.html)
-
Good man, Lee!
Thanks a ton.
-
Good man, Lee!
Thanks a ton.
You're very welcome 8-)