TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Giuseppe Beatrice on September 06, 2016, 06:22:21 AM
-
I have a really strange problem.
If I want to insert a block definition without inserting the block in the drawing, I have to use the instruction:
(command <full name of the block> nil)
All goes perfectly, but if I use a slightly different type of instruction it's not so more:
- with (command-s <full name of the block> nil) I have an error ... (command-s) unknown
- with (vl-cmdf <full name of the block> nil) I have an error ... Application Error: Invalid type sent as input comand
Can anyone please explain why these strangeness happens?
Thanks in advance.
-
A block name is not a command name. Why not just use insert or a variant thereof?
-
Since vl-cmdf evaluates the validity of the arguments prior to submitting them to the command-line, this expression will error if supplied with invalid input.
-
I regret for the lack of clarity; of course the complete instruction was (command "_.-insert" <ful-name-block> nil).
Many thanks Lee, you have lighted up my ignorance; then, even command-s return an error for the same reason.
Is there another way but (command "_.-insert" <ful-name-block> nil) to insert a block without inserting an instance of it in the drawing?
-
I would insert the block and delete the new instance
(vl-cmdf "._insert" blk
"_S" 1.0 "_R" 0.0 "_non" "0,0,0") (princ "Block Insertion Error") )
-
There's always this.
http://www.lee-mac.com/copyblockdefinition.html (http://www.lee-mac.com/copyblockdefinition.html)
From Lee Mac....
-
This isn't quite the same thing but it's inevitable someone will want to copy a block def between docs (which can be ODBX docs) ...
(defun _CopyBlockDef ( sourcedoc blockname targetdoc / block )
(and
(null
(vl-catch-all-error-p
(setq block
(vl-catch-all-apply
(function
(lambda ( )
(vla-item
(vla-get-blocks sourcedoc)
blockname
)
)
)
)
)
)
)
(null
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ( )
(vlax-invoke-method
sourceDoc
'CopyObjects
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbObject
'(0 . 0)
)
(list block)
)
(vla-get-blocks targetdoc)
)
)
)
)
)
)
)
FWIW cheers.
-
You may get some ideas from this old program: Import Block (http://lee-mac.com/copyblockfromdrawing.html).
-
I'm bewildered.
Have you tried the built in ADCENTER ??
The DesignCenter was designed to replicate table data.
It doesn't handle UCS's, but I imagine there are several shared versions on the site.
added: here's one from 9 years ago https://www.theswamp.org/index.php?topic=16994.msg205851#msg205851
-
Your availability is huge and I can only thank you all.
I think theswamp is the best site to learn Lisp. :yay!: