DuanJinHui Posted April 8, 2016 Share Posted April 8, 2016 (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 Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 8, 2016 Share Posted April 8, 2016 Maybe Lee Mac's Get Anonymous References lisp routine will provide you with some insight and perhaps help to solve your problem. http://www.lee-mac.com/getanonymousreferences.html Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 8, 2016 Share Posted April 8, 2016 Simply because they are not Dynamic Blocks. Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 8, 2016 Share Posted April 8, 2016 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? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 8, 2016 Share Posted April 8, 2016 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. Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 8, 2016 Share Posted April 8, 2016 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 8, 2016 Share Posted April 8, 2016 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' . Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 8, 2016 Share Posted April 8, 2016 I see I misunderstood the exact nature of Lee's program. Thank you for the explanation. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 8, 2016 Share Posted April 8, 2016 I see I misunderstood the exact nature of Lee's program. Thank you for the explanation. Not a problem, my pleasure. Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted April 8, 2016 Author Share Posted April 8, 2016 Thanks ,Tharwat and ReMark @Tharwat In my drawing. have 1 Normal Block and 2 Anonymous blocks, why you say no Anonymous block ? Quote Link to comment Share on other sites More sharing options...
Jef! Posted April 8, 2016 Share Posted April 8, 2016 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: AUDITFix 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... Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 8, 2016 Share Posted April 8, 2016 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 Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 8, 2016 Share Posted April 8, 2016 Wonkie CAD habits will bite you in the backside every time. "We have met the enemy and they are us." Quote Link to comment Share on other sites More sharing options...
Jef! Posted April 8, 2016 Share Posted April 8, 2016 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." Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted April 9, 2016 Author Share Posted April 9, 2016 @Jef! @SLW210 Thank you both. Thank you for tell my the reason. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 9, 2016 Share Posted April 9, 2016 @Tharwat In my drawing. have 1 Normal Block and 2 Anonymous blocks, why you say no Anonymous block ? @Jef! @SLW210Thank you both. Thank you for tell my the reason. It is good that you know now. Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted April 10, 2016 Author Share Posted April 10, 2016 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! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2016 Share Posted April 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted April 10, 2016 Author Share Posted April 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2016 Share Posted April 10, 2016 Thank you very much ! Tharwat.Very good recommendations. Good luck. Let me know if you need any further help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.