See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: Move a Block to its correct Elevation after reading elevation data from an Attribute

  1. #1
    I could stop if I wanted to JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Move a Block to its correct Elevation after reading elevation data from an Attribute

    Would anyone have a LISP that would read an attribute and then move it's coresponding block to the elevation listed in the attribute?

    Surveyor sent me a file and instead of using LDD points like I told him to he inserted blocks with shot#, elev,desc, as attributes but put all the blocks at 0 instead of there actuall elevations.
    Loyalty above all else except honor
    For my honor is my life!

  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: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Will this work? Please notice the two lines that need editing about the middle of the routine.
    Code:
    (DEFUN C:ADJUSTZ (/ CNT ENTITY PNT SS1 ZELEV ASC FIND_ATT )
      ;;; retrieve assoc data from entity
      (defun ASC (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
    
      ;;; Third Party Routine
      (DEFUN FIND_ATT (E TAG / FOUND) ; begin FIND_ATT
        (IF	E ; check for existence of ENAME
    	  ; is selected object a BLOCK
          (IF (= (CDR (ASSOC 0 (ENTGET E))) "INSERT")
    	  ; does it contain ATTRIBUTES
    	(IF (= (CDR (ASSOC 66 (ENTGET E))) 1)
    	  (PROGN ; loop til correct ATTRIBUTE
    	    (WHILE (NOT FOUND)
    	      (IF E ; do not use an entget unless you have an entity
    		(PROGN
    		  (IF (= (CDR (ASSOC 2 (ENTGET E))) (STRCASE TAG))
    		    (SETQ FOUND T) ; break loop if found
    		    (SETQ E (ENTNEXT E))
    	  ; if not correct ATT get next ATT
    		  ) ;end if
    		  (IF FOUND ; return ename if found
    		    E
    		  ) ;end if
    		) ;end progn
    		(PROGN ; if no match, tell me
    		  (PRINC "\nNo matching attribute found.")
    		  (SETQ FOUND T)
    	  ; break out of while loop by faking it out
    		  NIL ; return nil if not found
    		) ;end progn
    	      ) ;end if
    	    ) ; end while
    	  ) ; end progn
    	  (PROGN ; if no ATTR, tell me
    	    (PROMPT "\nBlock has no ATTRIBUTES ")
    	    NIL
    	  ) ;end progn
    	) ; end if
    	(PROGN
    	  (PROMPT "\nNot a block ") ; if not a block, tell me
    	  NIL
    	) ; end progn
          )	  ; end if
          (PROGN
    	(PROMPT "\nNothing selected ") ; if nothing selected, tell me
    	NIL
          )	  ;end progn
        )	  ; end if
      )
    
      ;;; Set Attribute Name
      (SETQ ATTRIBNAME "ZC")
      (SETQ	SS1 (SSGET '((0 . "INSERT")
    		     (2 . "X") ;<-Adjust Block Name here
    		    )
    	    )
      )
      (IF SS1
        (PROGN
          (SETQ CNT (SSLENGTH SS1))
          (REPEAT CNT
    	  ;(WHILE (NOT (SETQ ENTITY (ENTSEL "\nSelect X block: "))))
    	(SETQ ENTITY (ENTGET (SSNAME SS1 (SETQ CNT (1- CNT))))
    	      PNT    (ASC 10 ENTITY)
    	)
    
    	(IF (VL-STRING-SEARCH
    	      "X"
    	      (VLA-GET-EFFECTIVENAME
    		(VLAX-ENAME->VLA-OBJECT (ASC -1 ENTITY))
    	      )
    	    )
    	  (SETQ	ZELEV (FIND_ATT (ASC -1 ENTITY) ATTRIBNAME)
    	  )
    	)
    	(IF ZELEV
    	  (SETQ ZELEV (ASC 1 (ENTGET ZELEV)))
    	)
    	(IF (NUMBERP ZELEV)
    	  (SETQ PNT (LIST (CAR PNT) (CADR PNT) ZELEV))
    	  (SETQ PNT (LIST (CAR PNT) (CADR PNT) (ATOF ZELEV)))
    	)
    	(SETQ ENTITY (SUBST (CONS 10 PNT) (ASSOC 10 ENTITY) ENTITY))
    	(ENTMOD ENTITY)
          )
        )
      )
    )
    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 JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Wer'e close.

    Got throught the renames no prob but now get this error;

    Select objects: 1 found
    Select objects: ; error: no function definition: VLA-GET-EFFECTIVENAME.

    Just starting with LISP and VLISP is still a little over my head.
    Loyalty above all else except honor
    For my honor is my life!

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

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Quote Originally Posted by Baghera
    Wer'e close.

    Got throught the renames no prob but now get this error;

    Select objects: 1 found
    Select objects: ; error: no function definition: VLA-GET-EFFECTIVENAME.

    Just starting with LISP and VLISP is still a little over my head.
    Try adding this to the beginning of the code.
    Code:
    (vl-load-com)
    If it is not that then it may be a dynamic block issue. This routine was created to work with a specific dynamic block.
    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
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    1

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Give this a try, not tested though absolutely
    Now is too late for me on it
    Let me know if this wouldn't to work for you

    Code:
    (defun C:che (/	bname elist ent i ip next next_data sset)
      (setvar "cmdecho" 0)
      (command "._undo" "_e")
      (command "._undo" "_g")
      (setq bname (getstring T "\nEnter block name (case-sensitive)\n"))
      
      (prompt "\nSelect blocks to change elevation\n")
      (setvar "nomutt" 1)
      (if (setq sset (ssget (list (cons 2 bname))) i -1)
        (progn
        (setvar "nomutt" 0)
        (while (setq ent (ssname sset (setq i (1+ i))))
          (setq elist (entget ent)
    	    ip (cdr (assoc 10 elist)))
          (setq next ent)
          (setq next    (entnext next)
               next_data (entget next))
          (while (not (eq "SEQEND" (cdr (assoc 0 next_data))))
    	(if
    		 (eq "ELEV" (cdr (assoc 2 next_data)))
    	  (progn
    	    (entmod
    	      (subst
    		 (cons 10 (list (car ip)(cadr ip)(atof (cdr (assoc 1 next_data)))))
    		 (assoc 10 elist) elist))
    	    (entupd ent)))
    	    (setq next_data (entget (entnext (cdr (assoc -1 next_data)))))
    	  )
    	)
          )
      
        (prompt (strcat "\n\tNo one blocks with name: "
    		    "\""		     bname
    		    "\""		     " in the drawing."
    		   )
        )
      )
    
      (command "regen")
      (setvar "cmdecho" 1)
      (command "._undo" "_e")
      (princ)
    )
    (prompt "\ntype CHE to execute ...")
    (princ)
    ~'J'~

  6. #6
    I could stop if I wanted to JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Still no luck. I do have a VLISP tutorial here though that 3 things that need to be put in every project are;

    (vl-load-comm)

    (setq acadApp (vlax-get-acad-object))

    (setq acadDoc (vla-get-activedocument acadapp))


    I added the lines above but still get the same error.
    Loyalty above all else except honor
    For my honor is my life!

  7. #7
    I could stop if I wanted to JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Quote Originally Posted by fixo
    Give this a try, not tested though absolutely
    Now is too late for me on it
    Let me know if this wouldn't to work for you
    ~'J'~
    Worked perfectly. Thanks a lot guys!!!
    Loyalty above all else except honor
    For my honor is my life!

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

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Quote Originally Posted by Baghera
    Still no luck. I do have a VLISP tutorial here though that 3 things that need to be put in every project are;

    (vl-load-comm)

    (setq acadApp (vlax-get-acad-object))

    (setq acadDoc (vla-get-activedocument acadapp))


    I added the lines above but still get the same error.
    Sorry it didn't work out for. I recently wrote that routine to my needs. I did not examine it thoroughly enough before posting if for you. I guess I'll have to start doing that more often.
    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

  9. #9
    I could stop if I wanted to JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Quote Originally Posted by Opie
    Sorry it didn't work out for. I recently wrote that routine to my needs. I did not examine it thoroughly enough before posting if for you. I guess I'll have to start doing that more often.
    Eh, no worries. Gave me something to look at and maybe get some ideas from when I get some down time. (which is next to never)
    Loyalty above all else except honor
    For my honor is my life!

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Move a Block to its correct Elevation after reading elevation data from an Attribute

    Quote Originally Posted by Baghera
    Worked perfectly. Thanks a lot guys!!!
    Glad if this helps
    Cheers

    ~'J'~

Similar Threads

  1. 2015: creating revit topo from autoCAD file with elevation data contained in editable attribute
    By nateofthewest in forum Revit Architecture - General
    Replies: 2
    Last Post: 2015-08-11, 05:58 PM
  2. change block elevation to match attribute value
    By SurveyorHead in forum AutoLISP
    Replies: 6
    Last Post: 2015-04-05, 03:23 AM
  3. Move blocks to attribute elevation
    By noitess in forum AutoCAD Civil 3D - General
    Replies: 0
    Last Post: 2010-09-19, 07:44 PM
  4. Making an elevation look correct
    By pcl in forum Revit Architecture - General
    Replies: 22
    Last Post: 2008-12-20, 01:05 AM
  5. Replies: 27
    Last Post: 2006-10-06, 01:04 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
  •