alanjt Posted June 2, 2009 Posted June 2, 2009 if you are going to use the rotate command, why not just eliminate it and just use the insert command to bring the block in, you can set the rotation while in the command, and you don't have to worry about using PAUSE. (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) (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))) (setq INPT (getpoint "\nGet insertion point:")) (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 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 3 "Door ID:") (cons 2 "ID") (cons 70 (cons 73 0) (cons 74 2))) (entmake (list (cons 0 "endblk") (cons 8 "0"))) (entmake (list (cons 0 "INSERT") (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 "attdef") (cons 67 0) (cons 410 "Model") (cons 8 TLNAM) (cons 10 AFAP01) (cons 40 ASIZ) (cons 1 "D01") (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 3 "Door ID:") (cons 2 "ID") (cons 70 (cons 73 0) (cons 74 2))) (entmake (list (cons 0 "SEQEND") (cons 8 "0"))) [color=Red](vl-cmdf "_.insert" "LDR" "_s" 1 INPT)[/color] ) (defun DTR (a) (* pi (/ a 180.0)) ) Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Hi alanjt, I am already using insert command in my IDS program. This is just an alternative to do the same thing with a different method. I am alway will to different things. This in not something that is a must get done. I have time to figure this out. But Thanks anyway. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 Buzzard, I notice in the INSERT section of the entmake process, you are erroneously using "ATTDEF" when it should be "ATTRIB". - this may solve your problems Quote
alanjt Posted June 2, 2009 Posted June 2, 2009 Hi alanjt, I am already using insert command in my IDS program. This is just an alternative to do the same thing with a different method. I am alway will to different things. This in not something that is a must get done. I have time to figure this out. But Thanks anyway. no prob, i totally understand here, you might like this. i got tired of retyping the same thing over and over, so i wrote a sub. ;;; Insert block into drawing ;;; #Name - name of block ;;; #InsPt - insert point ;;; #XScale - block X scale ;;; #YScale - block Y scale ;;; #Rot - block rotation ;;; Alan J. Thompson, 04.21.09 (defun AT:InsertBlock (#Name #InsPt #XScale #YScale #Rot) (if (or (tblsearch "block" #Name) (findfile #Name) ) ;_ or (vla-insertblock ((if (eq (getvar "cvport") 1) vla-get-paperspace vla-get-modelspace ) ;_ if (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ vla-get-ActiveDocument ) (vlax-3d-point #InsPt) #Name #XScale #YScale #XScale #Rot ) ;_ vla-insert-block ) ;_ if ) ;_ defun Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 Yes Buzzard - I believe Alan is right. It is time for you to get stuck into Visual LISP that you've been avoiding for so long... Quote
CAB Posted June 2, 2009 Posted June 2, 2009 David in your first set of lists, should that be an "ENDBLK", not "SEQEND" to finish the block definition. To create the BLOCK 1. Entmake the BLOCK entity. 2. Entmake one ATTDEF entity for each attribute. 3. Entmake a ENDBLK entity. To create the INSERT 1. Entmake the INSERT entity. 2. Entmake one ATTRIB entity for each attribute. 3. Entmake a SEQEND entity. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 I appreciate all the advice about the visual lisp coding, But I really think I need to grasp vanilla lisp a bit more, So thanks for the encouragement, But I will get there at some point. I made the fixes as indicated. Lee I had to change attdef to attrib. This was the main problem. The attribute and block now show up, But the attribute is now in the wrong position. If I do an insert of the block after using the routine the block comes in correctly. I know at that point I am using the correct calculations to position the attribute. Must be something interfering with this. I will need to disect the code a bit more. Below is what I have so far. (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) (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))) (setq INPT (getpoint "\nGet insertion point:")) (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 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"))) (entmake (list (cons 0 "INSERT") (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 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)) ) Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 Buzzard, the position could be due to your text position flags: (cons 72 1) (cons 11 ASAP01) ... (cons 74 2) Obviously DXF 11 is the alignment point, and you have 72 and 74 arranged for MIDDLE CENTER at present. [ just something to bear in mind ] Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 This is real strange. When I use the program to insert the block, The block inserts correctly with the attribute in the wrong position. When I use the program a second time in the same session, The block comes in and the attribute from the first insert highlights. When I move the second block the second attribute move off the top of the first attribute. It would seem as if all attribute were being inserted with respect to the UCS icon. I must be missing something here. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 I do have the attributes arranged for middle center, I calculate from the bottom left edge of the door. This should place the attribute in the middle between the door and end of the swing line. As mentioned, If you do an insert after running the program the door and attribute show correctly as intended. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 Also, make sure that all your points in the DXF tables are in WCS I'm running out of suggestions here... Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Because my IDS program was intended to create block definitions I made a variable call BRPT which is set to 0,0,0 so the definition will always be correct. I now changed this to INPT to where the block is inserted and this fixed it. See below where I comment out BRPT and replace others with INPT. Also needed to move the prompt above the calcs. (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) (setq INPT (getpoint "\nGet insertion point:")) ; (setq BRPT (list 0.0 0.0 0.0)) (setq EXDR (list 0.0 0.0 1.0)) (setq PT01 (polar INPT (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 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 "block") (cons 2 BNAM) (cons 10 INPT) (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 INPT) (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"))) (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)) ) Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 When using entmake to create and insert the block without the insert command, It seems you need to position off the insertion point rather THAN a common reference point beacuse the insertion point now becomes the reference point. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 Also notice the THAN incase of Grammer Nazi's. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 When using entmake to create and insert the block without the insert command, It seems you need to position off the insertion point rather THAN a common reference point beacuse the insertion point now becomes the reference point. I'm not sure what you mean by this? EDIT: actually I think I do, and I think I know what went wrong. When creating the block definition using the entmake, you spcified all points relative to the origin and this was the base point. Then, upon insertion, the insertion point was the user selected point - but the attribute insertion points were still relative to the origin. To make things simple, I would still create the block definition with the base point at the origin, as this will help when inserting it with different base points. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 When you build a block for insertion, You create the block definition with a common reference point such as 0,0,0. In this case we are building a block on the fly using entmake to insert it. Another word we are going direct to the block definition every time and the insertion point since it can be anywhere in the drawing editor now becomes this point. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 It still worked out, After using the routine, I did an insert and the block still came in correct. Quote
Lee Mac Posted June 2, 2009 Posted June 2, 2009 It still worked out, After using the routine, I did an insert and the block still came in correct. I was considering cases in which you entmake the block definition, and insert it in multiple locations. This may get complicated if the block is not defined relative to the origin. Quote
The Buzzard Posted June 2, 2009 Author Posted June 2, 2009 I know what you mean, Maybe I need to review this a bit more, But as you can see It seems to work. I think what you are referring to is when you have to redefine the block at some point. Anyway I am comfortable with this method for now and will continue to test it before using it in any program. Thanks Lee Just the same thanks to Lee, David, Alan, and CAB for the help. Mission accomplished. This was an interesting thread. 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.