Questions about "BLOCK" entity type

Questions about "BLOCK" entity type

Browning_Zed
Advocate Advocate
842 Views
10 Replies
Message 1 of 11

Questions about "BLOCK" entity type

Browning_Zed
Advocate
Advocate

Greetings!

 

If there is a specific drawing file created with the "WBLOCK" command (the name of the block is equal to the name of the dwg file that contains only this block).
How to import such a block, but DO NOT insert the block into the drawing (ONLY IMPORT).
I tried to use the vla-InsertBlock function, specifying InsertionPoint - nil as an argument, thus:

(vla-InsertBlock (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) nil (strcat "Block_Name" ".dwg") 1 1 1 0)

In such a case, the block will be imported into the drawing, but the function evaluation will return an error.
Adding to the expression:

(vl-catch-all-error-p (vl-catch-all-apply ...)) does not fix the error.

So my question is: how can I import a block from an external file without error? I would not like to use for this command method.

 

My second question.
If the block exists in the drawing:
(tblsearch "BLOCK" "Block_Name") 
then I can determine if the block has attributes:
(= 2 (cdr (assoc 70 (tblsearch "BLOCK" "Block_Name"))))
Can I also determine if there are visibility parameters in the block WITHOUT INSERT the block into the drawing?

 

Thanks in advance to all who respond.

0 Likes
Accepted solutions (1)
843 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

You could use your insertion code, giving it whatever you like as an insertion point [e.g. 0,0,0 or (getvar 'viewctr)], and add after that part (entdel (entlast)).

 

OR, In the Design Center [ADC command alias], you can choose a Block, pick the Insert-one option, and as soon as you do, the Block definition will have been brought in.  In the Insert dialog box you can then just pick Cancel, so you don't need to go through with an Insertion of it.

Kent Cooper, AIA
Message 3 of 11

Browning_Zed
Advocate
Advocate

Thanks for the feedback, Kent.

I'm primarily interested in how to do this with Lisp. I managed to import the block without error using:
(command "_.INSERT" "Block_Name" nil)
In this case, the block is imported without being inserted into the drawing and without error. But I'm wondering if there is a way to import a block with a NON-COMMAND method.

 


@Kent1Cooper  написал (-а):

You could use your insertion code, giving it whatever you like as an insertion point [e.g. 0,0,0 or (getvar 'viewctr)], and add after that part (entdel (entlast)).


I know this way, but I would like to avoid "insert".

0 Likes
Message 4 of 11

john.uhden
Mentor
Mentor

@Browning_Zed 

Your vla-insertblock does avoid using (command), so take the rest of @Kent1Cooper 's suggestion and entdel it after the insertion.  Are you sure you can't "catch" the error?

John F. Uhden

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

I confess to being curious about why one would want to bring in a Block definition but not have any insertion(s) of it.  If it's to have it available to use later, wait until later and bring it in then with an insertion.  If you're never going to have any insertion of it, it's wasteful of memory to carry the definition of it in the drawing file.

Kent Cooper, AIA
0 Likes
Message 6 of 11

Browning_Zed
Advocate
Advocate

Unfortunately, I couldn't catch the error and the code fails.

0 Likes
Message 7 of 11

Browning_Zed
Advocate
Advocate

Well, I'll try to explain. I'm trying to create a subroutine that has the following structure:
1. Checking if a block exists in a drawing
2. Checking if the block contains attributes and/or visibility states. If True, then start a dynamic DCL dialog where attributes and visibility states are defined.
3. Get a selection set by filtering blocks and points and replacing these objects with a block with pre-set parameters and attributes.

0 Likes
Message 8 of 11

pbejse
Mentor
Mentor

@Browning_Zed wrote:

How to import such a block, but DO NOT insert the block into the drawing (ONLY IMPORT).

 You use "ObjectDBX.AxDbDocument"  and vla-copyobjects.

 


@Browning_Zed wrote:

Can I also determine if there are visibility parameters in the block WITHOUT INSERT the block into the drawing?


Yes you can test all that before you import the block

Now, if the block is already exists and not inserted-- > getDynBlockRecord _Giles 

 

HTH

 

 

 

Message 9 of 11

Browning_Zed
Advocate
Advocate

_gile function is great, but it also requires an entity inserted into the drawing, just like Lee Mac functions.

Thanks for the vla-copyobjects tip, I'll try that.

0 Likes
Message 10 of 11

pbejse
Mentor
Mentor
Accepted solution

@Browning_Zed wrote:

_gile function is great, but it also requires an entity inserted into the drawing,


No sir. you need to supply tblobjname then you will get the parameter names.

 

 

(if (setq f (tblobjname "BLOCK" bname))
  (progn
    (getDynPropParams 
    	(entget (cdr (assoc 330 (entget f))))
	)
    )
  )

 

for example on the block "Arrows - Imperial"

You'll get this. use assoc to test for visibility name match

 

(("BLOCKROTATIONPARAMETER" "Angle")
  ("BLOCKLINEARPARAMETER" "Length")
  ("BLOCKFLIPPARAMETER" "Direction" ("Right" "Left"))
  ("BLOCKVISIBILITYPARAMETER"
    "Arrow Type"
    ("Single" "Arched" "Double" "Fancy" "Flex" "Tail")
  )
  ("BLOCKLINEARPARAMETER" "Tail Width")
)

 

 

HTH

 

Message 11 of 11

Browning_Zed
Advocate
Advocate

Oh, that's right. I'm sorry I didn't understand right away. Thanks for the solution.

0 Likes