Jump to content

Why I can't select the Anonymous block when I use this code.


DuanJinHui

Recommended Posts

(setq ss (ssget "_+.:S:E:L" '((0 . "INSERT") (2 . "`**"))))

 

Why I can't select the Anonymous block when I use this code.

 

I pick Anonymous block ,return :nil

test2.dwg

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    7

  • ReMark

    5

  • DuanJinHui

    5

  • tombu

    3

I thought the OP wanted to pick anonymous blocks not necessarily dynamic blocks? Can't some of what Lee Mac wrote help the OP to solve his problem?

Link to comment
Share on other sites

I thought the OP wanted to pick anonymous blocks not necessarily dynamic blocks? Can't some of what Lee Mac wrote help the OP to solve his problem?

 

As per their drawing it is only Normal Blocks, no Dynamic nor Anonymous.

Link to comment
Share on other sites

Yes, I agree, as per the OP's drawing they do appear to be anonymous blocks but he did title his thread and specifically ask about anonymous blocks. Either he made a mistake or he does not know what constitutes an anonymous block. Be that as it may I don't think you actually answered my previous question.

Link to comment
Share on other sites

Be that as it may I don't think you actually answered my previous question.

Lee's function is to get the original block name ( some people call it "real name") of the anonymous or dynamic blocks, but the OP wants to be able to pick straight on the block to assign the selection set to variable 'ss' .

Link to comment
Share on other sites

Thanks ,Tharwat and ReMark

 

@Tharwat

In my drawing. have 1 Normal Block and 2 Anonymous blocks, why you say no Anonymous block ?

Link to comment
Share on other sites

Why I can't select the Anonymous block when I use this code.

Because your block's names don't start with a "*".. their name are "lucas" and "New block-U2".

 

That being said, I was surprised that i could not inspect these 2 blocks in the vlide or by tblsearch

Command: (tblsearch "block" "New block-U2")

nil

Command: (tblsearch "block" "lucas")

nil

Command: (tblsearch "block" "abc")

((0 . "BLOCK") (2 . "abc") (70 . 0) (4 . "") (10 0.0 0.0 0.0) (-2 . ))

it seems they have not been made correctly because audit "fixed them"

Command: AUDIT

Fix any errors detected? [Yes/No] : y

Auditing Header

Auditing Tables

Auditing Entities Pass 1

Invalid anonymous block "LUCAS" found in Block symbol table.

Changed to normal block "AUDIT_I_160408132305-0".

Invalid anonymous block "New block-U2" found in Block symbol table.

Changed to normal block "AUDIT_I_160408132305-1".

Pass 1 100 objects audited

Auditing Entities Pass 2

Pass 2 100 objects audited

Auditing Blocks

6 Blocks audited

Auditing AcDsRecords

Total errors found 2 fixed 2

Erased 0 objects

 

The code who made these 2 blocks is the cause...

Link to comment
Share on other sites

Anonymous blocks will have a * at the beginning of the name.

 

BLOCK REFERENCE Layer: "0"

Space: Model space

Handle = 134

Block Name: "abc"

at point, X=69'-0 17/32" Y=51'-10 11/16" Z= 0'-0"

X scale factor: 25.40000

Y scale factor: 25.40000

rotation angle: 0.00000000

Z scale factor: 25.40000

InsUnits: Millimeters

Unit conversion: 0.03937

Scale uniformly: No

Allow exploding: Yes

 

BLOCK REFERENCE Layer: "0"

Space: Model space

Handle = 12e

Block Name: "New block-U2"

at point, X=137'-4 15/16" Y=56'-0 23/32" Z= 0'-0"

X scale factor: 25.40000

Y scale factor: 25.40000

Press ENTER to continue:

rotation angle: 0.00000000

Z scale factor: 25.40000

InsUnits: Millimeters

Unit conversion: 0.03937

Scale uniformly: No

Allow exploding: Yes

 

BLOCK REFERENCE Layer: "0"

Space: Model space

Handle = 128

Block Name: "LUCAS"

at point, X=105'-9 31/32" Y=48'-4 3/8" Z= 0'-0"

X scale factor: 25.40000

Y scale factor: 25.40000

rotation angle: 0.00000000

Z scale factor: 25.40000

InsUnits: Millimeters

Unit conversion: 0.03937

Scale uniformly: No

Allow exploding: Yes

Link to comment
Share on other sites

Anonymous blocks will have a * at the beginning of the name.

 

Very true.. my guess is that they were created with the anonymous dxfcode flag but with an invalid name... because they were not listed in the insert dialog, and trying to edit them gave that error

Command: _REFedit ** Cannot REFEDIT anonymous block **

 

"We have met the enemy and they are us."

:D

Link to comment
Share on other sites

@Tharwat

In my drawing. have 1 Normal Block and 2 Anonymous blocks, why you say no Anonymous block ?

 

@Jef! @SLW210

Thank you both. Thank you for tell my the reason.

 

It is good that you know now.

Link to comment
Share on other sites

It is good that you know now.

 

I use this code change Anonymous block to normal block.

 

;;Anonymous block change to normal block

(if (setq ss (ssget "_+.:S:E:L" '((0 . "INSERT") (2 . "`**"))))
(progn
	(setq pt (cdr(assoc 10(entget(ssname ss 0)))))
	(command "_.explode"  ss )
	(setq ss2 (ssget "p"))
	(emkblk ss2 pt n )
	(princ "\n>>>Complete!")
)
(alert "\nNot Anonymous block, please try again!...")
)

(defun emkblk (ss pt name / i)
(entmake (list '(0 . "block") (cons 2 name) '(70 . 0) (cons 10 pt)))
(repeat (setq i (sslength ss))    (entmake (cdr (entget (ssname ss (setq i (1- i))))))  )
(entmake '((0 . "ENDBLK")))
(command "_.erase" ss "")
(entmake (list '(0 . "INSERT") (cons 2 name) (cons 10 pt)))
)

 

Is there a better way to do this ? Any suggestions ? Thanks!

Link to comment
Share on other sites

Hi Duan,

 

A few recommendations if you'd like;

 

  • The block name must be unique and you should use the function tablsearch function to check if the New Block Name is not already existed into your current drawing.
  • The block name also must be valid , so use the function snvalid to check the name out.
  • Final thing which might be necessarily to check if the Block is Explodable, if so, you can go ahead and create your new block definition without any error that might take a place.
     
  • Also one more thing that considered essential any time you are trying to modify object(s) in AutoCAD is to check if objects are not on LOCKED layer, if so , unlock the layer or cancel the process ( as you wish of course ).

 

Good luck.

Link to comment
Share on other sites

Hi Duan,

 

A few recommendations if you'd like;

 

  • The block name must be unique and you should use the function tablsearch function to check if the New Block Name is not already existed into your current drawing.
  • The block name also must be valid , so use the function snvalid to check the name out.
  • Final thing which might be necessarily to check if the Block is Explodable, if so, you can go ahead and create your new block definition without any error that might take a place.
     
  • Also one more thing that considered essential any time you are trying to modify object(s) in AutoCAD is to check if objects are not on LOCKED layer, if so , unlock the layer or cancel the process ( as you wish of course ).

 

Good luck.

 

Thank you very much ! Tharwat.

Very good recommendations. :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...