Author Topic: vlax-ename of a BLOCK (definition), not of an INSERT  (Read 3268 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 650
vlax-ename of a BLOCK (definition), not of an INSERT
« on: November 19, 2014, 05:58:46 AM »
Based on Lee Macs functions for Dynamic Blocks I tried to works withs "Blocks", not with "Inserts". I want to check the allowed visibility-props and then create an "insert".

The creation of "vlax-ename" works fine with "inserts":

Code: [Select]
(setq blockobj (vlax-ename->vla-object (car (entsel))))
Objekt wählen:
#<VLA-OBJECT IAcadBlockReference 00000000312d1c38>

But I tried it with blockdefinitions, and it returns a Line-object:

Code: [Select]
(setq blockobj (cdr (assoc -2 (tblsearch "block" selBlock)))) ; -> <Objektname: 7ffffb0a3c0>
(setq blockobj (vlax-ename->vla-object blockobj)) ; -> #<VLA-OBJECT IAcadLine 0000000031720308>

Which Dummy-Error is behind it?

Thanks
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #1 on: November 19, 2014, 06:27:12 AM »
That object that you've obtained after (tblsearch) is actually first entity that belongs to that block definition... To get block definition itself try to use (vlax-ename->vla-object (tblobjname "BLOCK" (cdr (assoc 2 (entget (car (entsel))))))), or in your case (vlax-ename->vla-object (tblobjname "BLOCK" selBlock))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Peter2

  • Swamp Rat
  • Posts: 650
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #2 on: November 19, 2014, 06:34:32 AM »
But your code still uses an "entsel" to select an Insert, but I want to read it from block-definition.

Code - Auto/Visual Lisp: [Select]
  1. (setq myblock "testblock")
  2. -> show dynprops of myblock
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #3 on: November 19, 2014, 06:49:02 AM »

Peter2,
Help yourself.
Post a minimal drawing containing enough data for someone to help you.
You have asked enough questions here and elsewhere that you should be able to ask questions and provide enough data so the issue isn't confusing to those who are trying to help.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Peter2

  • Swamp Rat
  • Posts: 650
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #4 on: November 19, 2014, 07:11:02 AM »
Hi

sorry if sometimes my questions are not precise enough.

Attached is a drawing, with one dynamic block-definition and one insert of it. The block has

- 1 visibility parameter with
- 3 visibility values.

I want to create a function which
1) selects a block-definition by its name (tblsearch?, tblobjname?)
2) analyse the visibility-parameters and values (see Lee Macs code http://www.lee-mac.com/dynamicblockfunctions.html) and display them
3) insert the block
4) modify its visibility

All four steps seem to be clear for itself, but I have the (maybe simple) problem between step 1) and 2) - to deliver the right data to the functions in step 2). I found some postings here, but they all use "ssget" or "entsel" to select the Insert.

I hope my problem is clearer now. Thanks in advance
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #5 on: November 19, 2014, 07:13:00 AM »
Compared with the relative simplicity of the ActiveX properties & methods available in Visual LISP, Dynamic block properties are not too easily to manipulate using Vanilla AutoLISP (as they are stored in several dictionaries & nested dictionaries within the extension dictionary of the block record entity).

However, to point you in the right direction & give you an 'entry point' for these dictionaries, start with the following:

BLOCK entity:
_$ (elist (tblobjname "block" "test"))
  (
    (-1 . <Entity name: 7ffffb0b710>)
    (0 . "BLOCK")
    (330 . <Entity name: 7ffffb0b700>)
    (5 . "41C9")
    (100 . "AcDbEntity")
    (67 . 0)
    (8 . "0")
    (100 . "AcDbBlockBegin")
    (70 . 0)
    (10 0.0 0.0 0.0)
    (-2 . <Entity name: 7ffffb0b800>)
    (2 . "test")
    (1 . "")
  )


BLOCK RECORD entity:
_$ (elist (cdr (assoc 330 (entget (tblobjname "block" "test")))))
  (
    (-1 . <Entity name: 7ffffb0b700>)
    (0 . "BLOCK_RECORD")
    (5 . "41C8")
    (102 . "{ACAD_XDICTIONARY")
    (360 . <Entity name: 7ffffb0b810>)
    (102 . "}")
    (330 . <Entity name: 7ffffb03810>)
    (100 . "AcDbSymbolTableRecord")
    (100 . "AcDbBlockTableRecord")
    (2 . "test")
    (360 . <Entity name: 7ffffb0b710>)
    (340 . <Entity name: 0>)
    ...
    < binary data encoding block image >
    ...

    (102 . "{BLKREFS")
    (331 . <Entity name: 7ffffb0b740>)
    (102 . "}")
    (70 . 4)
    (280 . 1)
    (281 . 0)
    (-3
      (
        "AcDbDynamicBlockTrueName"
        (1000 . "test")
      )
      (
        "AcDbDynamicBlockGUID"
        (1000 . "{F4D1B14E-94D1-4003-B853-AF16DF2C3A49}")
      )
      (
        "AcDbBlockRepETag"
        (1070 . 1)
        (1071 . 1)
      )
    )
  )


BLOCK RECORD Extension Dictionary:
_$ (elist (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "block" "test"))))))))
  (
    (-1 . <Entity name: 7ffffb0b810>)
    (0 . "DICTIONARY")
    (330 . <Entity name: 7ffffb0b700>)
    (5 . "41D1")
    (100 . "AcDbDictionary")
    (280 . 1)
    (281 . 1)
    (3 . "ACAD_ENHANCEDBLOCK")
    (360 . <Entity name: 7ffffb0b820>)
    (3 . "AcDbDynamicBlockRoundTripPurgePreventer")
    (360 . <Entity name: 7ffffb0b8d0>)
  )


ACAD_ENHANCEDBLOCK Dictionary:
_$ (elist (dictsearch (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "block" "test"))))))) "ACAD_ENHANCEDBLOCK"))
  (
    (-1 . <Entity name: 7ffffb0b820>)
    (0 . "ACAD_EVALUATION_GRAPH")
    (5 . "41D2")
    (102 . "{ACAD_REACTORS")
    (330 . <Entity name: 7ffffb0b810>)
    (102 . "}")
    (330 . <Entity name: 7ffffb0b810>)
    (100 . "AcDbEvalGraph")
    ...
    < unimportant DXF groups >
    ...

    (360 . <Entity name: 7ffffb0b850>) ;; <-- BLOCKVISIBILITYPARAMETER
    ...
    < unimportant DXF groups >
    ...

    (360 . <Entity name: 7ffffb0b860>) ;; <-- BLOCKVISIBILITYGRIP
    ...
    < unimportant DXF groups >
    ...

    (360 . <Entity name: 7ffffb0b870>) ;; <-- BLOCKGRIPLOCATIONCOMPONENT
    ...
    < unimportant DXF groups >
    ...

    (360 . <Entity name: 7ffffb0b880>) ;; <-- BLOCKGRIPLOCATIONCOMPONENT
    ...
    < unimportant DXF groups >
    ...

  )


Dynamic Block Visibility Parameter:
_$ (elist (cdr (assoc 360 (dictsearch (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "block" "test"))))))) "ACAD_ENHANCEDBLOCK"))))
  (
    (-1 . <Entity name: 7ffffb0b850>)
    (0 . "BLOCKVISIBILITYPARAMETER")
    (330 . <Entity name: 7ffffb0b820>)
    (5 . "41D5")
    (100 . "AcDbEvalExpr")
    (90 . 2)
    (98 . 31)
    (99 . 57)
    (100 . "AcDbBlockElement")
    (300 . "Visibility State")
    (98 . 31)
    (99 . 57)
    (1071 . 0)
    (100 . "AcDbBlockParameter")
    (280 . 1)
    (281 . 0)
    (100 . "AcDbBlock1PtParameter")
    (1010 0.0 0.0 0.0)
    (93 . 3)
    (170 . 0)
    (171 . 0)
    (100 . "AcDbBlockVisibilityParameter")
    (281 . 1)
    (301 . "Visibility1")
    (302 . "")
    (91 . 0)
    (93 . 1)
    (331 . <Entity name: 7ffffb0b800>)
    (92 . 3)
    (303 . "VisibilityState0")
    (94 . 1)
    (332 . <Entity name: 7ffffb0b800>)
    (95 . 0)
    (303 . "VisibilityState1")
    (94 . 1)
    (332 . <Entity name: 7ffffb0b800>)
    (95 . 0)
    (303 . "VisibilityState2")
    (94 . 1)
    (332 . <Entity name: 7ffffb0b800>)
    (95 . 0)
  )

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #6 on: November 19, 2014, 07:15:22 AM »
I want to create a function which
1) selects a block-definition by its name (tblsearch?, tblobjname?)
2) analyse the visibility-parameters and values (see Lee Macs code http://www.lee-mac.com/dynamicblockfunctions.html) and display them
3) insert the block
4) modify its visibility

You may find this thread helpful:

http://www.theswamp.org/index.php?topic=45905.0

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #7 on: November 19, 2014, 07:31:46 AM »
I assume this topic is related to:
http://www.opendcl.com/forum/index.php?topic=2199.0

Peter2

  • Swamp Rat
  • Posts: 650
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #8 on: November 19, 2014, 08:55:31 AM »
You may find this thread helpful:
http://www.theswamp.org/index.php?topic=45905.0
Yes, I found this posting before. It brought me to other links and infos, and this is why I believe that some of my steps mentioned above are "clear". But the challenge is:
Quote from: Lee Mac in the linked thread
The function provides an interface through which a user may insert a dynamic block whose visibility state is already set to a predetermined value:
Before I can select a predetermined value I have to found which are allowed.

I assume this topic is related to:
http://www.opendcl.com/forum/index.php?topic=2199.0
Also "yes". In OpenDCL I try to find the "preview", but some dyn-props are already discussed here. This is why I started the thread here.

But now I have to merge all the infos around and will try which progress I can make.

Thanks to all posters for their contribution!
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlax-ename of a BLOCK (definition), not of an INSERT
« Reply #9 on: November 19, 2014, 12:59:33 PM »
You may find this thread helpful:
http://www.theswamp.org/index.php?topic=45905.0
Yes, I found this posting before. It brought me to other links and infos, and this is why I believe that some of my steps mentioned above are "clear". But the challenge is:
Quote from: Lee Mac in the linked thread
The function provides an interface through which a user may insert a dynamic block whose visibility state is already set to a predetermined value:
Before I can select a predetermined value I have to found which are allowed.

Attached is an earlier version of the 'Insert with Visibility State' function (before it became a subfunction) which demonstrates how to query the dynamic block for the available visibility states.

I hope this helps,

Lee