Jump to content

Insert Object with Entmake


The Buzzard

Recommended Posts

Hello to everyone,

 

Lee Mac gave me a suggestion for a block insertion code I made to insert the block by way of entmake instead of the insert command.

I took my best shot at it, and am almost there.

 

The attached program is a simple code of one object with an attribute that will pause for rotation angle after the insertion point is selected.

 

The defaults are programmed in since this is only a demo.

The program functions fine for the insertion with one exception.

The attribute is not part of the block. If you do an insert after running this program, The block appears with the attribute.

 

Not sure what is wrong, But would appreciate some adVice.

 

Thanks

The Buzzard

 

 

(defun C:LD ()                                                          ;Define Function
 (command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N") ;Style command
 (setq ASTY  "Romans")                                                 ;Attribute Style
 (setq AWID    1.0)                                                    ;Attribute Width Factor
 (setq ASIZ    4.5)                                                    ;Attribute Height
 (setq ALNAM "A-DOOR-IDEN")                                            ;Attribut Layer Name
 (setq BNAM  "LDR")                                                    ;Block Name
 (setq WID    36.0)                                                    ;Door Width
 (setq THK     2.0)                                                    ;Door Thickness
 (setq BRPT (list 0.0 0.0 0.0))                                        ;Base Reference Point
 (setq EXDR (list 0.0 0.0 1.0))                                        ;Extrusion Direction
 (setq PT01 (polar BRPT (DTR  90.0) WID))                              ;Calculate Door Point 01
 (setq PT02 (polar PT01 (DTR   0.0) THK))                              ;Calculate Door Point 02
 (setq PT03 (polar PT02 (DTR 270.0) WID))                              ;Calculate Door Point 03
 (setq PT04 (polar PT03 (DTR 180.0) THK))                              ;Calculate Door Point 04
 (setq SANG   0.0)                                                     ;Arc Start Angle
 (setq EANG   1.5708)                                                  ;Arc Ending Angle
 (setq AFAP   (polar BRPT (DTR 270.0)      11.25))                     ;Attribute First Alignment Point
 (setq AFAP01 (polar AFAP (DTR   0.0)      15.0))
 (setq ASAP   (polar BRPT (DTR 270.0)       6.75))                     ;Attribute Second Alignment Point
 (setq ASAP01 (polar ASAP (DTR   0.0)(/ WID 2.0)))
 (setq INPT (getpoint "\nGet insertion point:"))                       ;Insertion Point
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "block")                                                ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   BRPT)                                                  ;Object Base Reference Point
     (cons 70   2)))                                                   ;Attribute Flag ~ Has None Constant Attributes
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "LWPOLYLINE")                                           ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbPolyline")                                         ;Subclass Marker
     (cons 90   4)                                                     ;Number of Vertices
     (cons 70   1)                                                     ;Polyline Flag ~ Closed
     (cons 43   0.0)                                                   ;Constant width
     (cons 38   0.0)                                                   ;Elevation
     (cons 39   0.0)                                                   ;Thickness
     (cons 10   PT01)                                                  ;Vertex Coordinates ~ (Point 01)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT02)                                                  ;Vertex Coordinates ~ (Point 02)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT03)                                                  ;Vertex Coordinates ~ (Point 03)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT04)                                                  ;Vertex Coordinates ~ (Point 04)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 210  EXDR)))                                                ;Extrusion Direction
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "arc")                                                  ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbCircle")                                           ;Subclass Marker
     (cons 10   BRPT)                                                  ;Center Point ~ (Base Reference Point)
     (cons 39   0.0)                                                   ;Thickness
     (cons 40   WID)                                                   ;Arc Radius ~ (Width)
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 100 "AcDbArc")                                              ;Subclass Marker
     (cons 50   SANG)                                                  ;Arc Start Angle
     (cons 51   EANG)))                                                ;Arc Ending Angle
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "attdef")                                               ;Object Type
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8    ALNAM)                                                 ;Attribute Layer Name
     (cons 10   AFAP01)                                                ;Attribute First Alignment Point
     (cons 40   ASIZ)                                                  ;Attribute Size ~ (4.5)
     (cons 1   "D01")                                                  ;Attribute Value
     (cons 50   0.0)                                                   ;Text Rotation
     (cons 41   AWID)                                                  ;Font Width Factor ~ (1.0)
     (cons 51   0.0)                                                   ;Oblique Angle
     (cons 7    ASTY)                                                  ;Attribute Style ~ (Romans)
     (cons 71   0)                                                     ;Text Generation Flag ~ (Default)
     (cons 72   1)                                                     ;Horiz. Text Justification ~ (Center)
     (cons 11   ASAP01)                                                ;Attribute Second Alignment Point
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 3   "Door ID:")                                             ;Attribute Prompt
     (cons 2   "ID")                                                   ;Attribute Tag
     (cons 70                                                        ;Attribute Visibility Flag ~ (Attribute Is Preset (No Prompt During Insertion) 
     (cons 73   0)                                                     ;Field Length
     (cons 74   2)))                                                   ;Vertical Text Justification ~ (Middle)
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "endblk")))                                             ;Object Type
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "INSERT")                                               ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   INPT)))                                                ;Insertion Point
 (prompt "\nRotation Angle: ")                                         ;Prompt For Rotation
 (command "_.rotate" "last" "" INPT pause)                             ;Rotate Command, Last Object, Rotate On Insertion Point, Pause For Input
)                                                                       ;End Define Function
(defun DTR (a)                                                          ;Define Function
(* pi (/ a 180.0))                                                     ;Calculate Degrees To Radians
)                                                                       ;End Define Function

Link to comment
Share on other sites

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    42

  • Lee Mac

    17

  • David Bethel

    5

  • alanjt

    5

This seems to work for me :huh:

 

PS, I have added another way to prompt for the rotation if you wanted to go down that route :)

 

(defun C:LD ()                                                          ;Define Function
 (command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N") ;Style command
 (setq ASTY  "Romans")                                                 ;Attribute Style
 (setq AWID    1.0)                                                    ;Attribute Width Factor
 (setq ASIZ    4.5)                                                    ;Attribute Height
 (setq ALNAM "A-DOOR-IDEN")                                            ;Attribut Layer Name
 (setq BNAM  "LDR")                                                    ;Block Name
 (setq WID    36.0)                                                    ;Door Width
 (setq THK     2.0)                                                    ;Door Thickness
 (setq BRPT (list 0.0 0.0 0.0))                                        ;Base Reference Point
 (setq EXDR (list 0.0 0.0 1.0))                                        ;Extrusion Direction
 (setq PT01 (polar BRPT (DTR  90.0) WID))                              ;Calculate Door Point 01
 (setq PT02 (polar PT01 (DTR   0.0) THK))                              ;Calculate Door Point 02
 (setq PT03 (polar PT02 (DTR 270.0) WID))                              ;Calculate Door Point 03
 (setq PT04 (polar PT03 (DTR 180.0) THK))                              ;Calculate Door Point 04
 (setq SANG   0.0)                                                     ;Arc Start Angle
 (setq EANG   1.5708)                                                  ;Arc Ending Angle
 (setq AFAP   (polar BRPT (DTR 270.0)      11.25))                     ;Attribute First Alignment Point
 (setq AFAP01 (polar AFAP (DTR   0.0)      15.0))
 (setq ASAP   (polar BRPT (DTR 270.0)       6.75))                     ;Attribute Second Alignment Point
 (setq ASAP01 (polar ASAP (DTR   0.0)(/ WID 2.0)))
 (setq INPT (getpoint "\nGet insertion point:"))                       ;Insertion Point
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "block")                                                ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   BRPT)                                                  ;Object Base Reference Point
     (cons 70   2)))                                                   ;Attribute Flag ~ Has None Constant Attributes
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "LWPOLYLINE")                                           ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbPolyline")                                         ;Subclass Marker
     (cons 90   4)                                                     ;Number of Vertices
     (cons 70   1)                                                     ;Polyline Flag ~ Closed
     (cons 43   0.0)                                                   ;Constant width
     (cons 38   0.0)                                                   ;Elevation
     (cons 39   0.0)                                                   ;Thickness
     (cons 10   PT01)                                                  ;Vertex Coordinates ~ (Point 01)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT02)                                                  ;Vertex Coordinates ~ (Point 02)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT03)                                                  ;Vertex Coordinates ~ (Point 03)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT04)                                                  ;Vertex Coordinates ~ (Point 04)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 210  EXDR)))                                                ;Extrusion Direction
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "arc")                                                  ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbCircle")                                           ;Subclass Marker
     (cons 10   BRPT)                                                  ;Center Point ~ (Base Reference Point)
     (cons 39   0.0)                                                   ;Thickness
     (cons 40   WID)                                                   ;Arc Radius ~ (Width)
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 100 "AcDbArc")                                              ;Subclass Marker
     (cons 50   SANG)                                                  ;Arc Start Angle
     (cons 51   EANG)))                                                ;Arc Ending Angle
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "attdef")                                               ;Object Type
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8    ALNAM)                                                 ;Attribute Layer Name
     (cons 10   AFAP01)                                                ;Attribute First Alignment Point
     (cons 40   ASIZ)                                                  ;Attribute Size ~ (4.5)
     (cons 1   "D01")                                                  ;Attribute Value
     (cons 50   0.0)                                                   ;Text Rotation
     (cons 41   AWID)                                                  ;Font Width Factor ~ (1.0)
     (cons 51   0.0)                                                   ;Oblique Angle
     (cons 7    ASTY)                                                  ;Attribute Style ~ (Romans)
     (cons 71   0)                                                     ;Text Generation Flag ~ (Default)
     (cons 72   1)                                                     ;Horiz. Text Justification ~ (Center)
     (cons 11   ASAP01)                                                ;Attribute Second Alignment Point
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 3   "Door ID:")                                             ;Attribute Prompt
     (cons 2   "ID")                                                   ;Attribute Tag
     (cons 70                                                        ;Attribute Visibility Flag ~ (Attribute Is Preset (No Prompt During Insertion) 
     (cons 73   0)                                                     ;Field Length
     (cons 74   2)))                                                   ;Vertical Text Justification ~ (Middle)
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "endblk")))                                             ;Object Type
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "INSERT")                                               ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   INPT)                                                  ;Insertion Point
[color=Red][b]      ;(cons 50  (getangle INPT "\nSelect Rotation: "))                 ;Rotation Angle[/b][/color]
     ))
 (prompt "\nRotation Angle: ")                                         ;Prompt For Rotation
 (command "_.rotate" "last" "" INPT pause)                             ;Rotate Command, Last Object, Rotate On Insertion Point, Pause For Input
)                                                                       ;End Define Function
(defun DTR (a)                                                          ;Define Function
(* pi (/ a 180.0))                                                     ;Calculate Degrees To Radians
)                                                                       ;End Define Function

Link to comment
Share on other sites

I do not understand, You are telling me the attribute appears?

 

Sorry, did not check for attribute :oops:

 

*Won't be so quick next time*

Link to comment
Share on other sites

OK, this will insert with ATTRIB, but you will see the problem I'm getting...

 

(defun C:LD ()                                                          ;Define Function
 (command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N") ;Style command
 (setq ASTY  "Romans")                                                 ;Attribute Style
 (setq AWID    1.0)                                                    ;Attribute Width Factor
 (setq ASIZ    4.5)                                                    ;Attribute Height
 (setq ALNAM "A-DOOR-IDEN")                                            ;Attribut Layer Name
 (setq BNAM  "LDR")                                                    ;Block Name
 (setq WID    36.0)                                                    ;Door Width
 (setq THK     2.0)                                                    ;Door Thickness
 (setq BRPT (list 0.0 0.0 0.0))                                        ;Base Reference Point
 (setq EXDR (list 0.0 0.0 1.0))                                        ;Extrusion Direction
 (setq PT01 (polar BRPT (DTR  90.0) WID))                              ;Calculate Door Point 01
 (setq PT02 (polar PT01 (DTR   0.0) THK))                              ;Calculate Door Point 02
 (setq PT03 (polar PT02 (DTR 270.0) WID))                              ;Calculate Door Point 03
 (setq PT04 (polar PT03 (DTR 180.0) THK))                              ;Calculate Door Point 04
 (setq SANG   0.0)                                                     ;Arc Start Angle
 (setq EANG   1.5708)                                                  ;Arc Ending Angle
 (setq AFAP   (polar BRPT (DTR 270.0)      11.25))                     ;Attribute First Alignment Point
 (setq AFAP01 (polar AFAP (DTR   0.0)      15.0))
 (setq ASAP   (polar BRPT (DTR 270.0)       6.75))                     ;Attribute Second Alignment Point
 (setq ASAP01 (polar ASAP (DTR   0.0)(/ WID 2.0)))
 (setq INPT (getpoint "\nGet insertion point:"))                       ;Insertion Point
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "block")                                                ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   BRPT)                                                  ;Object Base Reference Point
     (cons 70   2)))                                                   ;Attribute Flag ~ Has None Constant Attributes
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "LWPOLYLINE")                                           ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbPolyline")                                         ;Subclass Marker
     (cons 90   4)                                                     ;Number of Vertices
     (cons 70   1)                                                     ;Polyline Flag ~ Closed
     (cons 43   0.0)                                                   ;Constant width
     (cons 38   0.0)                                                   ;Elevation
     (cons 39   0.0)                                                   ;Thickness
     (cons 10   PT01)                                                  ;Vertex Coordinates ~ (Point 01)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT02)                                                  ;Vertex Coordinates ~ (Point 02)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT03)                                                  ;Vertex Coordinates ~ (Point 03)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT04)                                                  ;Vertex Coordinates ~ (Point 04)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 210  EXDR)))                                                ;Extrusion Direction
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "arc")                                                  ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbCircle")                                           ;Subclass Marker
     (cons 10   BRPT)                                                  ;Center Point ~ (Base Reference Point)
     (cons 39   0.0)                                                   ;Thickness
     (cons 40   WID)                                                   ;Arc Radius ~ (Width)
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 100 "AcDbArc")                                              ;Subclass Marker
     (cons 50   SANG)                                                  ;Arc Start Angle
     (cons 51   EANG)))                                                ;Arc Ending Angle
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "attdef")                                               ;Object Type
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8    ALNAM)                                                 ;Attribute Layer Name
     (cons 10   AFAP01)                                                ;Attribute First Alignment Point
     (cons 40   ASIZ)                                                  ;Attribute Size ~ (4.5)
     (cons 1   "D01")                                                  ;Attribute Value
     (cons 50   0.0)                                                   ;Text Rotation
     (cons 41   AWID)                                                  ;Font Width Factor ~ (1.0)
     (cons 51   0.0)                                                   ;Oblique Angle
     (cons 7    ASTY)                                                  ;Attribute Style ~ (Romans)
     (cons 71   0)                                                     ;Text Generation Flag ~ (Default)
     (cons 72   1)                                                     ;Horiz. Text Justification ~ (Center)
     (cons 11   ASAP01)                                                ;Attribute Second Alignment Point
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 3   "Door ID:")                                             ;Attribute Prompt
     (cons 2   "ID")                                                   ;Attribute Tag
     (cons 70                                                        ;Attribute Visibility Flag ~ (Attribute Is Preset (No Prompt During Insertion) 
     (cons 73   0)                                                     ;Field Length
     (cons 74   2)))                                                   ;Vertical Text Justification ~ (Middle)
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "endblk")))                                             ;Object Type
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "INSERT")                                               ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
[b][color=Red]      (cons 66   1)[/color][/b]
     (cons 10   INPT)                                                  ;Insertion Point
     ;(cons 50  (getangle INPT "\nSelect Rotation: "))                 ;Rotation Angle
     ))
 (prompt "\nRotation Angle: ")                                         ;Prompt For Rotation
 (command "_.rotate" (entlast) "" INPT pause)                             ;Rotate Command, Last Object, Rotate On Insertion Point, Pause For Input
)                                                                       ;End Define Function
(defun DTR (a)                                                          ;Define Function
(* pi (/ a 180.0))                                                     ;Calculate Degrees To Radians
)                                                                       ;End Define Function

 

Check highlight for change

Link to comment
Share on other sites

I like the idea about placing the prompt within the list. I did not know it could be done that way. I will use that. Anyway, I believe I am close to my goal, Most likely a few feet off.

Link to comment
Share on other sites

Reading up on the Group 66 code, I believe it should be done like this, but it doesn't seem to insert anything...

(defun C:LD ()                                                          ;Define Function
 (command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N") ;Style command
 (setq ASTY  "Romans")                                                 ;Attribute Style
 (setq AWID    1.0)                                                    ;Attribute Width Factor
 (setq ASIZ    4.5)                                                    ;Attribute Height
 (setq ALNAM "A-DOOR-IDEN")                                            ;Attribut Layer Name
 (setq BNAM  "LDR")                                                    ;Block Name
 (setq WID    36.0)                                                    ;Door Width
 (setq THK     2.0)                                                    ;Door Thickness
 (setq BRPT (list 0.0 0.0 0.0))                                        ;Base Reference Point
 (setq EXDR (list 0.0 0.0 1.0))                                        ;Extrusion Direction
 (setq PT01 (polar BRPT (DTR  90.0) WID))                              ;Calculate Door Point 01
 (setq PT02 (polar PT01 (DTR   0.0) THK))                              ;Calculate Door Point 02
 (setq PT03 (polar PT02 (DTR 270.0) WID))                              ;Calculate Door Point 03
 (setq PT04 (polar PT03 (DTR 180.0) THK))                              ;Calculate Door Point 04
 (setq SANG   0.0)                                                     ;Arc Start Angle
 (setq EANG   1.5708)                                                  ;Arc Ending Angle
 (setq AFAP   (polar BRPT (DTR 270.0)      11.25))                     ;Attribute First Alignment Point
 (setq AFAP01 (polar AFAP (DTR   0.0)      15.0))
 (setq ASAP   (polar BRPT (DTR 270.0)       6.75))                     ;Attribute Second Alignment Point
 (setq ASAP01 (polar ASAP (DTR   0.0)(/ WID 2.0)))
 (setq INPT (getpoint "\nGet insertion point:"))                       ;Insertion Point
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "block")                                                ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     (cons 10   BRPT)                                                  ;Object Base Reference Point
     (cons 70   2)))                                                   ;Attribute Flag ~ Has None Constant Attributes
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "LWPOLYLINE")                                           ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbPolyline")                                         ;Subclass Marker
     (cons 90   4)                                                     ;Number of Vertices
     (cons 70   1)                                                     ;Polyline Flag ~ Closed
     (cons 43   0.0)                                                   ;Constant width
     (cons 38   0.0)                                                   ;Elevation
     (cons 39   0.0)                                                   ;Thickness
     (cons 10   PT01)                                                  ;Vertex Coordinates ~ (Point 01)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT02)                                                  ;Vertex Coordinates ~ (Point 02)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT03)                                                  ;Vertex Coordinates ~ (Point 03)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 10   PT04)                                                  ;Vertex Coordinates ~ (Point 04)
     (cons 40   0.0)                                                   ;Starting width
     (cons 41   0.0)                                                   ;Ending width
     (cons 42   0.0)                                                   ;Bulge
     (cons 210  EXDR)))                                                ;Extrusion Direction
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "arc")                                                  ;Object Type
     (cons 100 "AcDbEntity")                                           ;Subclass Marker
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8   "0")                                                    ;Layer Name
     (cons 100 "AcDbCircle")                                           ;Subclass Marker
     (cons 10   BRPT)                                                  ;Center Point ~ (Base Reference Point)
     (cons 39   0.0)                                                   ;Thickness
     (cons 40   WID)                                                   ;Arc Radius ~ (Width)
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 100 "AcDbArc")                                              ;Subclass Marker
     (cons 50   SANG)                                                  ;Arc Start Angle
     (cons 51   EANG)))                                                ;Arc Ending Angle
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "attdef")                                               ;Object Type
     (cons 67   0)                                                     ;Object Space ~ Model
     (cons 410 "Model")                                                ;Layout Tab Name ~ Model
     (cons 8    ALNAM)                                                 ;Attribute Layer Name
     (cons 10   AFAP01)                                                ;Attribute First Alignment Point
     (cons 40   ASIZ)                                                  ;Attribute Size ~ (4.5)
     (cons 1   "D01")                                                  ;Attribute Value
     (cons 50   0.0)                                                   ;Text Rotation
     (cons 41   AWID)                                                  ;Font Width Factor ~ (1.0)
     (cons 51   0.0)                                                   ;Oblique Angle
     (cons 7    ASTY)                                                  ;Attribute Style ~ (Romans)
     (cons 71   0)                                                     ;Text Generation Flag ~ (Default)
     (cons 72   1)                                                     ;Horiz. Text Justification ~ (Center)
     (cons 11   ASAP01)                                                ;Attribute Second Alignment Point
     (cons 210  EXDR)                                                  ;Extrusion Direction
     (cons 3   "Door ID:")                                             ;Attribute Prompt
     (cons 2   "ID")                                                   ;Attribute Tag
     (cons 70                                                        ;Attribute Visibility Flag ~ (Attribute Is Preset (No Prompt During Insertion) 
     (cons 73   0)                                                     ;Field Length
     (cons 74   2)))                                                   ;Vertical Text Justification ~ (Middle)
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "endblk")))                                             ;Object Type
 (entmake                                                              ;Entmake
   (list                                                               ;Start List
     (cons 0   "INSERT")                                               ;Object Type
     (cons 2    BNAM)                                                  ;Object Name
     [b][color=Red](cons 66   1)[/color][/b]
     (cons 10   INPT)                                                  ;Insertion Point
     ;(cons 50  (getangle INPT "\nSelect Rotation: "))                 ;Rotation Angle
     ))
 [b][color=Red](entmake
   (list      
     (cons 0 "ATTRIB")
     (cons 8 "A-DOOR-IDEN")
     (cons 1 "D01")
     (cons 7 "Romans")
     (cons 2 "ID")))
 (entmake
   (list
     (cons 0 "SEQEND")
     (cons 8 "0")))[/color][/b]
 ;(prompt "\nRotation Angle: ")                                         ;Prompt For Rotation
 ;(command "_.rotate" (entlast) "" INPT pause)                             ;Rotate Command, Last Object, Rotate On Insertion Point, Pause For Input
)                                                                       ;End Define Function
(defun DTR (a)                                                          ;Define Function
(* pi (/ a 180.0))                                                     ;Calculate Degrees To Radians
)                           

Link to comment
Share on other sites

I recall something similar to this, But not the way it is being used here.

I tried this back many months ago and gave up on the idea. Thats why I went to the insert command in my code.

Link to comment
Share on other sites

I recall something similar to this, But not the way it is being used here.

I tried this back many months ago and gave up on the idea. Thats why I went to the insert command in my code.

 

True, but Entmake is always quicker than any "command-call" method I find.

 

I was half considering changing my piping program so that it used an entmake method to create the entities, but it would mean a complete re-write of the drafting programs... not a small task... :unsure:

Link to comment
Share on other sites

The method I am using here will work fine for a block alone as/is, But I set my program up with alot of attributes. This was a simple test to go about and see if this could be done, But its a little beyond me. I need to study it much further. I will look around and see whats out there.

 

Thanks for the help Lee,

The Buzzard

Link to comment
Share on other sites

I have used this method when entmaking blocks with no attributes, and I assumed it would be just as simple for blocks with attributes, but evidently not...

 

Sorry I could not be of more help to you Buzzard,

 

Lee

Link to comment
Share on other sites

Not a problem, The program works with the insert command method. There is no hurry on this for me. I have all the time in the world to figure this out. You can be sure that when I do find out, I will mention it to all.

Link to comment
Share on other sites

Not a problem, The program works with the insert command method. There is no hurry on this for me. I have all the time in the world to figure this out. You can be sure that when I do find out, I will mention it to all.

 

Coincidentally, I had the same problem in post #21 of this thread:

http://www.cadtutor.net/forum/showthread.php?t=36729&page=3

 

David Bethel knows a thing or two about entmaking attributed blocks, perhaps he can shed some light :P

Link to comment
Share on other sites

The minimum groups for an INSERT with ATTRIBs are in red ( that I remember anyway ): TEXTSTYLE must exist prior to calling (entmake)

 

For the block:

(entmake (list [color=Red](cons 0 "BLOCK")
              (cons 2 "block_name")
              (list 10 0 0 0)
              (cons 70 2)))

[/color](entmake (list [color=Red](cons 0 "ATTDEF")[/color]
              (cons 8 "0")
              [color=Red](cons 10 (list 0 0 0))[/color]
            [color=Red]  (cons 40 1)
              (cons 1 "")
              (cons 3 "")
              (cons 2 "tag_name")[/color]
              (cons 70 0)
              (cons 73 0)
              (cons 50 0)
              (cons 41 1)
              (cons 51 0)
              [color=Red](cons 7 (getvar "TEXTSTYLE")[/color]
              (cons 71 0)
              (cons 72 0)
              [color=Red](cons 11 (list 0 0 0))[/color]
              (cons 210 (list 0 0 1))
              (cons 74 0)
              (cons 62 256)
              (cons 39 0)
              (cons 6 "BYLAYER")))

(entmake (list [color=Red](cons 0 "ENDBLK")[/color]
              (cons 8 "0")))

For The INSERT:

(entmake (list [color=Red](cons 0 "INSERT")[/color]
              (cons 8 "0")
              [color=Red](cons 66 1)[/color]
              [color=Red](cons 2 "block_name")[/color]
[color=Red]               (cons 10 (list 0 0 0))[/color]
              (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 (list 0 0 1))
              (cons 62 256)
              (cons 39 0)
              (cons 6 "BYLAYER")))

(entmake (list [color=Red](cons 0 "ATTRIB")[/color]
              (cons 8 "0")
              [color=Red](cons 10 (list 0 0 0))[/color]
              [color=Red](cons 40 1)[/color]
             [color=Red] (cons 1 "")
              (cons 2 "tag_name")[/color]
              (cons 70 0)
              (cons 73 0)
              (cons 50 0)
              (cons 41 1)
              (cons 51 0)
              [color=Red](cons 7 (getvar "TEXTSTYLE")[/color])
              (cons 71 0)
              (cons 72 0)
[color=Red]               (cons 11 (list 0 0 0))[/color]
              (cons 210 (list 0 0 1))
              (cons 74 0)
              (cons 62 256)
              (cons 39 0)
              (cons 6 "BYLAYER")))
(entmake (list [color=Red](cons 0 "SEQEND")[/color]
              (cons 8 "0")))

I definitely would not have a (get) call inside an (entmake). Any nil return in the call stop (entmake) evaluations. It does not erase or undo anything prior to nil return.

 

This make debugging an entmake very difficult.

 

I recommend the (cons 8 "0") in any ENDBLK call or SEQEND entity. it defaults to CLAYER value and if that layer is empty, you will never be able to purge it.

 

Also watch out for groups 6 8 39 48 62 210 as they default to some odd preset values. They are not the same defaults as DXFIN uses.

 

I'll go back and check your code to see if anything that is missing or wrong jumps out at me.

 

I use this scenario very often for making BLOCKs on the fly. -David

Link to comment
Share on other sites

David in your first set of lists, should that be an "ENDBLK", not "SEQEND" to finish the block definition.

 

As for the "get" calls within the definitions, - not trying to pass the buck, but that is something I picked up from VovKa :P

 

EDIT: you picked it up too :P

Link to comment
Share on other sites

Hi David,

 

So what you are saying is that entmake for the attributes has to exist both in the block definition as well as insert.

Link to comment
Share on other sites

I made like picture, But it does not insert the block, However the block definition

is in the drawing.

Link to comment
Share on other sites

I have the minimum requirements for entmake in the code. I also feed all the variables from the top of the code, And I have the code arrange similar to yours.

 

See attached

 

(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")))
 (prompt "\nRotation Angle: ")
 (command "_.rotate" "last" "" INPT pause)
)
(defun DTR (a)
(* pi (/ a 180.0))
)

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...