Results 1 to 7 of 7

Thread: Help with an "entmake" routine

  1. #1
    Active Member
    Join Date
    2005-02
    Posts
    67
    Login to Give a bone
    0

    Default Help with an "entmake" routine

    I inherited this routine at my new job & I'd like to modify/improve it and then add some additional functionality. First, I want to change this routine so that it creates the text with middle justification and then inserts it at the center of the room. However, my first few attempts were only partially successful. I did manage to get the text middle justified, but it always inserted it at 0,0.

    Code:
     ;FUNCTION TO LABEL ROOM SIZES
     (defun C:RS (/ CL PT1 PT2 X1 Y1 X2 Y2 BY RMSIZE ANG D TX)
       (setvar "DIMZIN" 3)
      ; (setq CL (getvar "clayer"))
       (setq PT1 (getpoint "nLower left corner of room:"))
       (setq PT2 (getcorner "nUpper right corner of room:" PT1))
       (setq X1 (car PT1))
       (setq Y1 (cadr PT1))
       (setq X2 (car PT2))
       (setq Y2 (cadr PT2))
       (setq X (rtos (- X2 X1)))
       (setq Y (rtos (- Y2 Y1)))
       (setq BY " X ")
       (setq RMSIZE (strcat X BY))
       (setq RMSIZE (strcat RMSIZE Y))
       (setq ANG (angle PT1 PT2))
       (setq D (/ (distance PT1 PT2) 2))
       (setq TX (polar PT1 ANG D))
       (entmake (list '(0 . "TEXT")
     		 '(100 . "AcDbEntity")
     		 '(67 . 0)
     		 '(8 . "ROOMSIZE")
     		 '(100 . "AcDbText")
     		 (cons 10 TX)
     		 '(40 . 4.0)
     		 (cons 1 RMSIZE)
     		 '(7 . "X-HAND1F")
     		 '(100 . "AcDbText")
     		 '(73 . 0)
     	   )
       )
     ) ;end ROOMSIZE.lsp
    I want to further alter it to prompt for the room name, ceiling height, and flooring putting each on its proper layer & spacing them correctly. I've got the prompts & most of the mechanics figured out however, I'm still struggling to understand all the intricacy's of entmake to create & insert the text.

    Thanks in advance
    Last edited by Mike.Perry; 2005-10-13 at 04:40 PM. Reason: [CODE] tags added.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,681
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    Quote Originally Posted by tflaherty
    I inherited this routine at my new job & I'd like to modify/improve it and then add some additional functionality. First, I want to change this routine so that it creates the text with middle justification and then inserts it at the center of the room. However, my first few attempts were only partially successful. I did manage to get the text middle justified, but it always inserted it at 0,0.

    ;FUNCTION TO LABEL ROOM SIZES
    (defun C:RS (/ CL PT1 PT2 X1 Y1 X2 Y2 BY RMSIZE ANG D TX)
    (setvar "DIMZIN" 3)
    ; (setq CL (getvar "clayer"))
    (setq PT1 (getpoint "nLower left corner of room:"))
    (setq PT2 (getcorner "nUpper right corner of room:" PT1))
    (setq X1 (car PT1))
    (setq Y1 (cadr PT1))
    (setq X2 (car PT2))
    (setq Y2 (cadr PT2))
    (setq X (rtos (- X2 X1)))
    (setq Y (rtos (- Y2 Y1)))
    (setq BY " X ")
    (setq RMSIZE (strcat X BY))
    (setq RMSIZE (strcat RMSIZE Y))
    (setq ANG (angle PT1 PT2))
    (setq D (/ (distance PT1 PT2) 2))
    (setq TX (polar PT1 ANG D))


    (entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") '(67 . 0) '(8 . "ROOMSIZE") '(100 . "AcDbText")
    (cons 10 TX) '(40 . 4.0) (cons 1 RMSIZE) '(7 . "X-HAND1F") '(100 . "AcDbText") '(73 . 0)))


    );end ROOMSIZE.lsp

    I want to further alter it to prompt for the room name, ceiling height, and flooring putting each on its proper layer & spacing them correctly. I've got the prompts & most of the mechanics figured out however, I'm still struggling to understand all the intricacy's of entmake to create & insert the text.

    Thanks in advance
    On your entmake issue, to justify text other than left justification, you will need to set the group code 11 point location. This is the alignment point.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    you should try using ActiveX in place of entmake this list function will add your text for you
    and return a VBA text object
    Code:
    ;;(VbaAddText "text" (list x y z) 4 4)
    ;;By John W Anstaett 10/13/05
    ;;This function add a text object to modelspace
    ;; myText = the text to use
    ;; myPoint = list of the point
    ;; myHight = the text hight
    ;; myJustification = the Alignment
    ;;Alignment
    ;;acAlignment enum; read-write 
    ;;acAlignmentLeft = 0
    ;;acAlignmentCenter = 1
    ;;acAlignmentRight = 2
    ;;acAlignmentAligned = 3
    ;;acAlignmentMiddle = 4
    ;;acAlignmentFit = 5
    ;;acAlignmentTopLeft = 6 
    ;;acAlignmentTopCenter = 7
    ;;acAlignmentTopRight = 8
    ;;acAlignmentMiddleLeft = 9
    ;;acAlignmentMiddleCenter = 10
    ;;acAlignmentMiddleRight = 11
    ;;acAlignmentBottomLeft = 12
    ;;acAlignmentBottomCenter = 13
    ;;acAlignmentBottomRight = 14
    ;; the function return the textobj as a vbaobject
    ;; so you can use make other change to the object
    ;;Exp:
    ;;(vla-put-layer myreturn "layername")
    ;;(vla-put-width myreturn 0.5)
    ;;(vla-put-textstyle myreturn "newstyle")
    (vl-load-com) 
    ;;This function loads the extended AutoLISP functions provided
    ;;with Visual LISP. The Visual LISP extensions implement ActiveX
    ;;and AutoCAD reactor support through AutoLISP, and also provide
    ;;ActiveX utility and data conversion functions, dictionary handling
    ;;functions, and curve measurement functions. 
    ;;If the extensions are already loaded, vl-load-com does nothing
    
    (defun VbaAddText (myText myPoint myHight MyJustification / acadObject acadDocument myss myas myc vlss)
      (setq acadObject (vlax-get-acad-object));get Autocad object
      (setq acadDocument (vla-get-ActiveDocument acadObject));get the Activedocument object
      (setq acadModelSpace (VLA-GET-MODELSPACE acadDocument));get the modelspace block
      (setq mytextObj (vla-addtext acadModelSpace mytext (vlax-3d-point myPoint) myhight));add text
      (vla-put-Alignment mytextObj myJustification);set text Justification
      (setq mytextObj myTextobj);retrun the text object
    )
    Note:
    update to 2011
    I am using ADT 2007 08/06/2008

    PS. If you use any Code I post or Down Load Attachment I would like to know if it was helpful. So please post reply to this thread, on how you use the code or down load. Thank You

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,681
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    Quote Originally Posted by jwanstaett
    you should try using ActiveX in place of entmake this list function will add your text for you
    and return a VBA text object
    Code:
    ;;(VbaAddText "text" (list x y z) 4 4)
    ;;By John W Anstaett 10/13/05
    ;;This function add a text object to modelspace
    ;; myText = the text to use
    ;; myPoint = list of the point
    ;; myHight = the text hight
    ;; myJustification = the Alignment
    ;;Alignment
    ;;acAlignment enum; read-write 
    ;;acAlignmentLeft = 0
    ;;acAlignmentCenter = 1
    ;;acAlignmentRight = 2
    ;;acAlignmentAligned = 3
    ;;acAlignmentMiddle = 4
    ;;acAlignmentFit = 5
    ;;acAlignmentTopLeft = 6 
    ;;acAlignmentTopCenter = 7
    ;;acAlignmentTopRight = 8
    ;;acAlignmentMiddleLeft = 9
    ;;acAlignmentMiddleCenter = 10
    ;;acAlignmentMiddleRight = 11
    ;;acAlignmentBottomLeft = 12
    ;;acAlignmentBottomCenter = 13
    ;;acAlignmentBottomRight = 14
    ;; the function return the textobj as a vbaobject
    ;; so you can use make other change to the object
    ;;Exp:
    ;;(vla-put-layer myreturn "layername")
    ;;(vla-put-width myreturn 0.5)
    ;;(vla-put-textstyle myreturn "newstyle")
    (vl-load-com) 
    ;;This function loads the extended AutoLISP functions provided
    ;;with Visual LISP. The Visual LISP extensions implement ActiveX
    ;;and AutoCAD reactor support through AutoLISP, and also provide
    ;;ActiveX utility and data conversion functions, dictionary handling
    ;;functions, and curve measurement functions. 
    ;;If the extensions are already loaded, vl-load-com does nothing
    
    (defun VbaAddText (myText myPoint myHight MyJustification / acadObject acadDocument myss myas myc vlss)
      (setq acadObject (vlax-get-acad-object));get Autocad object
      (setq acadDocument (vla-get-ActiveDocument acadObject));get the Activedocument object
      (setq acadModelSpace (VLA-GET-MODELSPACE acadDocument));get the modelspace block
      (setq mytextObj (vla-addtext acadModelSpace mytext (vlax-3d-point myPoint) myhight));add text
      (vla-put-Alignment mytextObj myJustification);set text Justification
      (setq mytextObj myTextobj);retrun the text object
    )
    What if the text is not in model space?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,681
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    Also, if you change the alignment insertion point but do not set the point it would move the text object to 0,0,0.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    Active Member
    Join Date
    2005-02
    Posts
    67
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    Quote Originally Posted by richardl.25628
    On your entmake issue, to justify text other than left justification, you will need to set the group code 11 point location. This is the alignment point.


    Wouldn't that be the same as the variable TX which is the center point of the room? So, I'd have two cons statments using the same variable (cons 10 TX) (cons 11 (tx)?

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,681
    Login to Give a bone
    0

    Default Re: Help with an "entmake" routine

    Quote Originally Posted by tflaherty
    Wouldn't that be the same as the variable TX which is the center point of the room? So, I'd have two cons statments using the same variable (cons 10 TX) (cons 11 (tx)?
    Yes and No. I have not found a way to set the text insertion point to the correct location, but fortunately when you do set the alignment and insertion points to the same points, AutoCAD will place the insertion point in the right location. Otherwise, the developer would need to calculate both points for the entmake to work.

    Also, don't place the the tx in parens when creating a dotted pair
    Code:
    (cons 11 tx) ;<- Correct
    (cons 11 (tx) ;<- Incorrect
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  2. ENTIDADES EN ALIGNMENT COMO "FIXED", "FLOTING" y "FREE"
    By cadia in forum Español - AutoCAD Civil 3D
    Replies: 1
    Last Post: 2009-02-01, 04:21 AM
  3. Replies: 5
    Last Post: 2008-02-19, 11:33 PM
  4. Replies: 6
    Last Post: 2006-12-07, 11:42 PM
  5. Replies: 3
    Last Post: 2005-10-11, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •