TimSpangler Posted June 2, 2009 Posted June 2, 2009 When I create blocks using entmake. I create them at 0,0 then I entmake the INSERT at a selected point, otherwise you can run into some craziness (as you have found, I think) Definitely keep that in mind. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Ok, So I am not done yet. This code example keeps the block definition in its own function. The insert section now is in its own function. Please test and let me know what you find. (defun C:LD () (command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N") (setq ASTY "Romans") (setq AWID 1.0) (setq ASIZ 4.5) (setq TLNAM "A-DOOR-IDEN") (setq BNAM "LDR") (setq WID 36.0) (setq THK 2.0) (if (null (tblsearch "block" BNAM) ) (LD_DEF) ) (setq INPT (getpoint "\nGet insertion point:")) (setq AFAP (polar INPT (DTR 270.0) 11.25)) (setq AFAP01 (polar AFAP (DTR 0.0) 15.0)) (setq ASAP (polar INPT (DTR 270.0) 6.75)) (setq ASAP01 (polar ASAP (DTR 0.0)(/ WID 2.0))) (entmake (list (cons 0 "INSERT") (cons 67 0) (cons 410 "Model") (cons 8 "0") (cons 66 1) (cons 2 BNAM) (cons 10 INPT) (cons 41 1) (cons 42 1) (cons 50 0) (cons 43 1) (cons 70 0) (cons 71 0) (cons 44 0) (cons 45 0) (cons 210 EXDR) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER"))) (entmake (list (cons 0 "attrib") (cons 67 0) (cons 410 "Model") (cons 8 TLNAM) (cons 10 AFAP01) (cons 40 ASIZ) (cons 1 "D01") (cons 2 "ID") (cons 70 (cons 73 0) (cons 50 0.0) (cons 41 AWID) (cons 51 0.0) (cons 7 ASTY) (cons 71 0) (cons 72 1) (cons 11 ASAP01) (cons 210 EXDR) (cons 74 2))) (entmake (list (cons 0 "SEQEND") (cons 8 "0"))) (prompt "\nRotation Angle: ") (command "_.rotate" "last" "" INPT pause) ) (defun DTR (a) (* pi (/ a 180.0)) ) (defun LD_DEF () (setq BRPT (list 0.0 0.0 0.0)) (setq EXDR (list 0.0 0.0 1.0)) (setq PT01 (polar BRPT (DTR 90.0) WID)) (setq PT02 (polar PT01 (DTR 0.0) THK)) (setq PT03 (polar PT02 (DTR 270.0) WID)) (setq PT04 (polar PT03 (DTR 180.0) THK)) (setq SANG 0.0) (setq EANG 1.5708) (setq AFAP (polar BRPT (DTR 270.0) 11.25)) (setq AFAP01 (polar AFAP (DTR 0.0) 15.0)) (setq ASAP (polar BRPT (DTR 270.0) 6.75)) (setq ASAP01 (polar ASAP (DTR 0.0)(/ WID 2.0))) (entmake (list (cons 0 "block") (cons 2 BNAM) (cons 10 BRPT) (cons 70 2))) (entmake (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 67 0) (cons 410 "Model") (cons 8 "0") (cons 100 "AcDbPolyline") (cons 90 4) (cons 70 1) (cons 43 0.0) (cons 38 0.0) (cons 39 0.0) (cons 10 PT01) (cons 40 0.0) (cons 41 0.0) (cons 42 0.0) (cons 10 PT02) (cons 40 0.0) (cons 41 0.0) (cons 42 0.0) (cons 10 PT03) (cons 40 0.0) (cons 41 0.0) (cons 42 0.0) (cons 10 PT04) (cons 40 0.0) (cons 41 0.0) (cons 42 0.0) (cons 210 EXDR))) (entmake (list (cons 0 "arc") (cons 100 "AcDbEntity") (cons 67 0) (cons 410 "Model") (cons 8 "0") (cons 100 "AcDbCircle") (cons 10 BRPT) (cons 39 0.0) (cons 40 WID) (cons 210 EXDR) (cons 100 "AcDbArc") (cons 50 SANG) (cons 51 EANG))) (entmake (list (cons 0 "attdef") (cons 67 0) (cons 410 "Model") (cons 8 TLNAM) (cons 10 AFAP01) (cons 40 ASIZ) (cons 1 "D01") (cons 3 "Door ID:") (cons 2 "ID") (cons 70 (cons 73 0) (cons 50 0.0) (cons 41 AWID) (cons 51 0.0) (cons 7 ASTY) (cons 71 0) (cons 72 1) (cons 11 ASAP01) (cons 210 EXDR) (cons 74 2))) (entmake (list (cons 0 "endblk") (cons 8 "0"))) ) Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 After I insert several blocks thru the program, I do a conventional insert to 0,0 and explode the block. Next I redefine it and all checks out OK. I beleive this is the ticket. I hope. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 The block definition reference is 0,0,0. There should be no problem with this. Quote
TimSpangler Posted June 2, 2009 Posted June 2, 2009 The block definition reference is 0,0,0. There should be no problem with this. That should be on the money.... Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Thanks Tim, I thought so. I needed to look at the insert section as a function in it own right. Also adjusted the attribute variable at that point also. The key is the tablesearch for the block. If not found go to the block function. Now this establishes the block definition. I now readjust the attribute variable before the insert is done not changing the block definition in any way. Quote
TimSpangler Posted June 2, 2009 Posted June 2, 2009 That sounds about right. I typically check for the block (tblsearch) if it isn't there I then create the BLOCK definition then I create the INSERT(S) from there. All separate sub functions. It is easier to control errors that way. IMHO Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Not much different than the way I normally do it, Except I needed to change the coordinates of the attribute before the insertion. The block definition attribute coordinates are with respect to 0,0,0. I notice there is not a big difference in the amount of programming involved between this method and a conventional insert method. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 One thing I have not found out yet is, What are the advantages to using this method over the insert command? Quote
TimSpangler Posted June 2, 2009 Posted June 2, 2009 I will the insert command if I need a "visual" aspect when inserting. Otherwise I use entmake. I believe it is faster and it eliminates the human error. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Lee, On a previous post you mention that this method is quicker than a command callout. I beleive it is hard to tell the difference. Are there any key differences? Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Thanks Tim, I think I know what you mean. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 In terms of human errors, I think it is all about how clever the programmer sets the program so that the user will not make errors. When I run my IDS program it seems very similar to the operation of this program. I do not get the visual until a point is selected , But you can learn to get use to this. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 Lee, On a previous post you mention that this method is quicker than a command callout. I beleive it is hard to tell the difference. Are there any key differences? I believe the entmake option is definitely quicker than the command call - you are cutting out the middle-man Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 I took another good look at this. As you are aware, The IDS program uses eleven attributes for each block with one being visible and ten being invisible. This method would require almost double the amount of programming to accomplish the same goal. This method seems OK for blocks with minimal attributes or no attributes. With almost double coding would seem not as quicker as one might think. I beleive one must evaluate the benifits over the obstacles carefully before using a method like this. Now do not get me wrong, I do like this method, But for a code such as my IDS program, This method would not be a benifit at all. I am glad that I got this figured out and will use this method where I feel will be less time consuming. To All This Was Quite An Experience, Thanks Again, The Buzzard Quote
TimSpangler Posted June 2, 2009 Posted June 2, 2009 If nothing else, it is always great to learn another way. You never know when you may need to use the back road... Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Without a doubt. I did get alot from this and as I said earlier I tried to go down this road once before, But never could figure it out. At some point I need to find this out. Now was just a good a time as any. There is nothing wrong at all with having many methods available to you. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 I also have learnt quite a bit from this, as I didn't know how to entmake attributed blocks - only simple ones. Thanks, Lee Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 I know what you mean Lee, However I find that entmake is faster for blocks with small amounts of attributes and loose objects that are not blocks. It would not pay to go this route for blocks with massive amounts of attributes for the extra coding involved and the program process time to process the extra lines. But in the long run there was alot to learn from a simple little code. I thought this was a very interesting thread to say the least. Thanks for the input. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 I know what you mean Lee, However I find that entmake is faster for blocks with small amounts of attributes and loose objects that are not blocks. It would not pay to go this route for blocks with massive amounts of attributes for the extra coding involved and the program process time to process the extra lines. But in the long run there was alot to learn from a simple little code. I thought this was a very interesting thread to the least. Thanks for the input. Of course, vla-insertblock is also a much faster alternative - with a lot less coding than entmake.. Quote
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.