See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: Autolisp entget

  1. #1
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Angry Autolisp entget

    Oh boy, Good Morning, I am trying some simple lisp stuff which always worked, but today I am trying to go in an object using 'entget'. I am looking for 'assoc 6' and 'assoc 48' but they don't show in the 'entget' table. I am selecting a pline with 'ssget' to obtain the object information. I have a routine that has been working but today it is crashing ????
    Thankyou, Jim

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

    Default Re: Autolisp entget

    SSGET provides a selection set. You will need to use SSNAME to extract entities out of the selection set to then query. Are you using that function? Can you share your code for review?

    Also, I moved your thread to the AutoLISP programming forum to get more eyes that are programming knowledgeable on this issue.
    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
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Autolisp entget

    Thanks, This is portion of the code, The results for linetype and linetype scale dont seem in the information extracted ??

    Code:
    (setq pt01 linest)
    (setq pt02 (polar pt01 (+ (dtr lineangl)(dtr 0)) lineeach))
    (setq pt03 (polar linest (+ (dtr lineangl)(dtr 0)) 2.0))
    (setq layrchk (ssget pt03) layrchk (ssname layrchk 0) layrchk (cdr (entget layrchk)) layrchk (cdr (assoc 8 layrchk)) );extract layer
    (setvar "clayer" layrchk)  
    (setq typechk (ssget pt03) typechk (ssname typechk 0) typechk (entget typechk) typechk (cdr (assoc 6 typechk)) );extract linetype   
    ;(setvar "celtype" typechk)
    (setq typesca (ssget pt03) typesca (ssname typesca 0) typesca (entget typesca) typesca (cdr (assoc 48 typesca)) );extract linetype scale   
    (command "erase" pt03 "")
    Any help would be great, I do know how to combine the testing into a shorter request but I dont think that will solve my question.
    Thanks
    Last edited by Opie; 2021-01-11 at 08:19 PM. Reason: [code] tags added

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Autolisp entget

    With all the properties set to the default ByLayer
    Code:
    (entget(car(entsel)))
    isn't going to give you anything but the layer name and endpoint coordinates.
    This could be done easier by converting the entity to an object and getting the properties from it but if you want the linetype it's displayed you would need to get that from the layer table.

  5. #5
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Autolisp entget

    Thankyou, I tried 'entsel' and then view via 'entget' and still dont get 'assoc 6' or 'assoc 48'. I am trying to test a pline/line for its linetype and linetype scale so I can apply these 2 to the new line.

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Autolisp entget

    Quote Originally Posted by brooks71 View Post
    Thankyou, I tried 'entsel' and then view via 'entget' and still dont get 'assoc 6' or 'assoc 48'. I am trying to test a pline/line for its linetype and linetype scale so I can apply these 2 to the new line.
    Because they are set to ByLayer there isn't anything assigned to them. Change the polyline's linetype and scale and try it again.

    By converting it to an object you can retrieve all properties even if they're ByLayer. Of course if you set an object on a different layer to ByBlock it will only display the same linetype and scale if the two layers are both set the same.

    Just saying what you're trying to do isn't as simple as you think.

    As an example this lisp by Peter Jamtgaard will display all the properties of a selected object even if they're ByLayer:
    Code:
    ; Written By: Peter Jamtgaard
    ;Menu item: ^P(or C:VDOT (load "VDOT.lsp"));VDOT
    (defun C:VDOT ()
     (vdot)
    )
    (defun VDOT (/ OBJ ColorObj)
     (princ "\nSelect object to examine methods and properties: ")
     (vl-load-com)
     (vlax-dump-object 
      (setq OBJ (vlax-ename->vla-object 
                 (car (entsel "\nSelect Object: "))
                )
      )
      T
     ); TrueColor
     (princ "\n(vlax-get-property OBJ 'Color) = ")(princ (vlax-get-property OBJ 'Color))
    ; (if(=(vla-get-ObjectName OBJ) "AcDbMText")
     (if(vla-get-TrueColor OBJ)
     (progn
       (setq ColorObj (vla-get-TrueColor OBJ)
              EntityColor (vla-get-EntityColor ColorObj)
       )
    ;   (vla-setRGB EntityColor 150 200 202)
       (vlax-dump-object ColorObj T)
    ;   (vlax-dump-object EntityColor T)
    ;   (vlax-dump-object (setq ColorObj (vla-get-TrueColor OBJ)) T)
       (princ "\nEntityColor = ")(princ EntityColor)
       (princ "\nColorObj = ")(princ ColorObj)
       (princ"\n")
       ; alternatively done as below
    ;   (vlax-invoke-method  ColorObj 'setRGB 150 200 20)
    ;   (vla-get-ColorIndex ColorObj)
     )
    
    ;   (vlax-dump-object ColorObj T)
     )
     (textscr)
     OBJ
    )
    
    (defun C:GET_ELST (/ ELST ENAM ETYP)
     (princ "\nSelect object to examine Entity List:\n ")
     (setq ENAM (car (entsel "\nSelect Object: "))
           ELST (entget ENAM)
     )
     (princ "\n\n")
     (princ ELST)
     (if (= (cdr (assoc 66 ELST)) 1)
      (while 
       (and
        (entnext ENAM)
        (or
         (= (setq ENAM (entnext ENAM)
                  ELST (entget  ENAM)
                  ETYP (cdr (assoc 0 ELST))
            )
            "ATTRIB"
         )
         (= ETYP "VERTEX")
         (= ETYP "SEQEND")
        )
       )
       (princ "\n\n")
       (princ  ELST)      
      )  
     )
     (textscr)
     (prin1)
    )
    (prin1)

  7. #7
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Autolisp entget

    Thank you very much, I will certainly look at this code and self teach the techniques. In the meantime, my routine can re-create the desired pline from 1 segment to multiple segments (user specified) in the same location, length, angle etc. Once done the routine simply runs the pline through autocad 'matchprop' command to reset the linetype and linetype scale.
    Thanks again and great skill. (should be good, I am not a 'vla' user)

  8. #8
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    1

    Default Re: Autolisp entget

    Using entget is possible but ActiveX properties is much easier.

    Here are two routines that help you understand how to get and put the COM linetypescale property.

    notice the (vl-load-com) as the last line. It loads activex functions.

    The errortrap wrapper on the activex call just protects the function from errors. Returns T or value for success and nil for failure.

    P=

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard C.E., P.E., S.E. copyright 2020 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Abstract: These command line functions allow a user to select an object and get the linetypescale property
    ; or change the linetypescale property after entering the new value.
    ; (These functions are easily changed to modify other activex properties.)
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Comand line function list
    ;___________________________________________________________________________________________________________|
    
    ;* C:LTS
    ;* Command line function to get and return a linetype scale on a selected object
    
    ;* C:LinetypeScale
    ;* Command line function to get and return a linetype scale on a selected object
    
    ;* C:LTSP
    ;* Command line function to change a linetype scale on a selected object
    
    ;* C:LinetypeScalePut 
    ;* Command line function to change a linetype scale on a selected object
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General function list
    ;___________________________________________________________________________________________________________|
    
    ;* (ErrorTrap symFunction)
    ;* General error trap function
    
    ;$ EndHeader
    
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Command line function to get and return a linetype scale on a selected object
    ;___________________________________________________________________________________________________________
    
    (defun C:LTS ()(C:LinetypeScale))
    
    (defun C:LinetypeScale (/ entSelection lstSelection objSelection)
     (if (and (princ "\nSelect object to get linetype scale: \n")
              (setq lstSelection (entsel))
              (setq entSelection (car lstSelection))
              (setq objSelection (vlax-ename->vla-object entSelection))
         )
      (errortrap '(vla-get-linetypescale objSelection))
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Command line function to change a linetype scale on a selected object
    ;___________________________________________________________________________________________________________
    
    (defun C:LTSP ()(C:LinetypeScalePut))
    
    (defun C:LinetypeScalePut (/ entSelection lstSelection objSelection sngLinetypeScale)
     (if (and (princ "\nSelect object to put linetype scale: \n")
              (setq lstSelection     (entsel))
              (setq entSelection     (car lstSelection))
              (setq objSelection     (vlax-ename->vla-object entSelection))
              (setq sngLinetypeScale (getdist "\nEnter Linetype Scale: "))
         )
      (errortrap '(vla-put-linetypescale objSelection sngLinetypeScale))
     )
    )
    
    
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; General error trap function
    ;___________________________________________________________________________________________________________
    
    (defun ErrorTrap (symFunction / objError result)
     (if (not
          (vl-catch-all-error-p
           (setq objError (vl-catch-all-apply
                          '(lambda (X)(set X (eval symFunction)))
                           (list 'result)))))
      (if result result 'T)
     )
    )
    
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2021-01-12 at 08:24 PM.
    AutomateCAD

  9. #9
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: Autolisp entget

    If you prefer Autolisp entget / entmod functions...

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard C.E., P.E., S.E. copyright 2021 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Abstract: These command line functions allow a user to select an object and get the linetypescale property
    ; or change the linetypescale property after entering the new value.
    ; (These functions are easily changed to modify other properties using entmod/entget techniques.)
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Comand line function list
    ;___________________________________________________________________________________________________________|
    
    ;* C:LTS
    ;* Command line function to get and return a linetype scale on a selected object
    
    ;* C:LinetypeScale
    ;* Command line function to get and return a linetype scale on a selected object
    
    ;* C:LTSP
    ;* Command line function to change a linetype scale on a selected object
    
    ;* C:LinetypeScalePut 
    ;* Command line function to change a linetype scale on a selected object
    
    
    ;$ EndHeader
    ;___________________________________________________________________________________________________________
    ; 
    ; Function to get the linetypescale of an object using entget
    ;___________________________________________________________________________________________________________
    
    (defun C:LTS ()(C:Linetypescale))
    (defun C:LinetypeScale (/ entSelection lstEntity lstSelection )
     (if (and (setq lstSelection (entsel "\nSelect Object: "))
              (setq entSelection (car lstSelection))
              (setq lstEntity    (entget entSelection))
              (or (setq sngLinetypeScale (cdr (assoc 48 lstEntity)))
                  (setq sngLinetypeScale 1.0)
              )
         )
      sngLinetypeScale
     )
    )
    
    ;___________________________________________________________________________________________________________
    ; 
    ; Function to change the linetypescale of an object using entmod
    ;___________________________________________________________________________________________________________
    
    (defun C:LTSP ()(C:LinetypeScalePut))
    (defun C:LinetypeScalePut (/ dprNew dprOld entSelection lstEntity lstSelection sngLinetypeScale)
     (if (and (setq sngLinetypeScale (getdist "\nEnter Linetype Scale: "))
              (setq lstSelection     (entsel "\nSelect Object: "))
              (setq entSelection     (car lstSelection))
              (setq lstEntity        (entget entSelection))
              (or (and (setq dprNew  (cons 48 sngLinetypeScale))
                       (setq dprOld  (assoc 48 lstEntity))
                       (setq lstEntity (subst dprNew
                                              dprOld
                                              lstEntity
                                       )
                       )
                  )
                  (setq lstEntity (append lstEntity
                                          (list dprNew)
                                  )
                  )
              )
         )
      (entmod lstEntity)
     )
    )
    (princ)
    Attached Files Attached Files
    AutomateCAD

Similar Threads

  1. Replies: 23
    Last Post: 2015-03-26, 08:31 PM
  2. Select & entget object information in XREF and block-in-block with Lisp
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-11-14, 09:11 AM
  3. Help with entget and assoc
    By domniki in forum AutoLISP
    Replies: 3
    Last Post: 2010-02-12, 07:39 PM
  4. Replies: 12
    Last Post: 2007-04-12, 09:57 PM
  5. Co-ordinate Autolisp programming
    By saifi2003 in forum AutoLISP
    Replies: 1
    Last Post: 2004-06-05, 03:16 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
  •