Author Topic: Strange behavior with the insertion of a block.  (Read 1812 times)

0 Members and 1 Guest are viewing this topic.

Giuseppe Beatrice

  • Newt
  • Posts: 43
Strange behavior with the insertion of a block.
« 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.

ChrisCarlson

  • Guest
Re: Strange behavior with the insertion of a block.
« Reply #1 on: September 06, 2016, 08:13:17 AM »
A block name is not a command name. Why not just use insert or a variant thereof?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Strange behavior with the insertion of a block.
« Reply #2 on: September 06, 2016, 08:26:25 AM »
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.

Giuseppe Beatrice

  • Newt
  • Posts: 43
Re: Strange behavior with the insertion of a block.
« Reply #3 on: September 06, 2016, 09:17:28 AM »
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?
« Last Edit: September 06, 2016, 09:20:36 AM by Giuseppe Beatrice »

ChrisCarlson

  • Guest
Re: Strange behavior with the insertion of a block.
« Reply #4 on: September 06, 2016, 10:15:42 AM »
I would insert the block and delete the new instance

Code - Auto/Visual Lisp: [Select]
  1. (if
  2.         (vl-cmdf "._insert" blk "_S" 1.0 "_R" 0.0 "_non" "0,0,0")
  3.                 (vl-cmdf "_.erase" (ssget "L") "")
  4.                 (princ "Block Insertion Error")
  5. )

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Strange behavior with the insertion of a block.
« Reply #5 on: September 06, 2016, 12:31:00 PM »
There's always this.

http://www.lee-mac.com/copyblockdefinition.html

From Lee Mac....

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Strange behavior with the insertion of a block.
« Reply #6 on: September 06, 2016, 12:51:32 PM »
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) ...

Code: [Select]
(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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Strange behavior with the insertion of a block.
« Reply #7 on: September 06, 2016, 04:11:25 PM »
You may get some ideas from this old program: Import Block.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Strange behavior with the insertion of a block.
« Reply #8 on: September 06, 2016, 07:17:03 PM »
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

« Last Edit: September 06, 2016, 07:22:39 PM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Giuseppe Beatrice

  • Newt
  • Posts: 43
Re: Strange behavior with the insertion of a block.
« Reply #9 on: September 07, 2016, 06:25:55 AM »
Your availability is huge and I can only thank you all.
I think theswamp is the best site to learn Lisp.  :yay!: