+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Computer Details
    StuboJones's Computer Details
    Operating System:
    Windows XP
    Computer:
    Latitude E5410
    CPU:
    Intel i3
    Monitor:
    Laptop
    Using
    AutoCAD 2011
    Join Date
    Nov 2008
    Location
    London
    Posts
    13

    Default Using block attribute value to create 3D point

    Registered forum members do not see this ad.

    Evening Gents,

    After searching through allot of threads as far back as 2006, I’m struggling a tad. Add to that that I’ve never produced a lisp in my life, you can understand I’m somewhat oblivious to what I'm about to ask, or whether I should be paying for it (had a similar experience in Amsterdam )

    I found and used the PMSFptwtx lisp to great effect, but stumbled when I tried to use it on a recent drawing from our architect. The levels that I wished to utilise were all embedded in a block as a variable value, which I’m assuming he/she would change with the attribute editor. Exploding the block would simply display the text 'LEVEL', which was of no use with the PMSFptwtx lisp.

    Is it possible to extract the variable value, and then create a 3D point from this at the blocks insertion point?

    Much appreciate your help

    Stu

  2. #2
    Junior Member
    Computer Details
    StuboJones's Computer Details
    Operating System:
    Windows XP
    Computer:
    Latitude E5410
    CPU:
    Intel i3
    Monitor:
    Laptop
    Using
    AutoCAD 2011
    Join Date
    Nov 2008
    Location
    London
    Posts
    13

    Default

    Cant tell this is my first time can you?
    Running ACAD2009.

  3. #3
    Senior Member wizman's Avatar
    Using
    AutoCAD 2009
    Join Date
    Nov 2007
    Location
    Abu Dhabi / Philippines
    Posts
    408

    Default

    here's a modified version for blocks...'-)
    Code:
    ;;;OriginalAuthor: Pedro Miguel da Silva Ferreira    Email:pedro_ferreira@netcabo.pt
    ;;;Web page: http:pwp.netcabo.pt/pedro_ferreira
    ;;;Location: Portugal, Lisboa
    ;;;Modified by Wizman 06NOV08
    ;;;***This version works for Blocks having attribute***
     
    (defun c:PMSFptwtxt (/
                 *modelspace*
                 aup_ini
                 cmd_ini
                 counter
                 diz_ini
                 edg_ini
                 fla_ini
                 letxt
                 lun_ini
                 ort_ini
                 osm_ini
                 plt_ini
                 txt
                 txtent
                 txtx
                 txty
                 txtz
                 uni_ini
                 xyz
                )
        (vl-load-com)
        (defun W1 (w1_ent / blk_tag enam eobj)
        (vl-load-com)
        (setq enam w1_ent)
        (setq eobj (vlax-ename->vla-object enam))
        (setq blk_tag w1_tagname)
        (setq txtz nil)
        (if (= (vla-get-hasattributes eobj) :vlax-true)
            (progn
            (foreach n (vlax-safearray->list
                       (variant-value
                       (vla-getattributes eobj)
                       ) ;_ end_variant-value
                   ) ;_ end_vlax-safearray->list
                (if    (= (strcase (vla-get-tagstring n))
                   (strcase blk_tag)
                ) ;_ end_=
                (if (numberp (read (vla-get-TextString n)))
                    (setq txtz (atof (vla-get-TextString n)))
                ) ;_ end_if
                ) ;_ end_if
            ) ;_ end_foreach
            ) ;_ end_progn
        ) ;_ end_if
        ) ;_ end_defun
    ;;;
     
    ;;;-------------------;;;
        (defun inivar ()
        (setq cmd_ini (getvar "cmdecho")
              fla_ini (getvar "flatland")
              osm_ini (getvar "osmode")
              ort_ini (getvar "orthomode")
              plt_ini (getvar "plinetype")
              aup_ini (getvar "auprec")
              uni_ini (getvar "unitmode")
              lun_ini (getvar "lunits")
              diz_ini (getvar "dimzin")
              edg_ini (getvar "edgemode")
        ) ;_ end_setq
        (setvar "CMDECHO" 0)
        (setvar "FLATLAND" 0)
        (setvar "OSMODE" 0)
        (setvar "ORTHOMODE" 0)
        (setvar "PLINETYPE" 2)
        (setvar "AUPREC" 0)
        (setvar "UNITMODE" 1)
        (setvar "LUNITS" 2)
        (setvar "DIMZIN" 0)
        (setvar "EDGEMODE" 1)
        ) ;_ end_defun
     
    ;;;
    ;;;Convert a list of reals into strings
        (defun linhaxy (px)
        (vl-princ-to-string px)
        ) ;_ end_defun
     
        (inivar)
     
    ;;;-------------------;;;
        (defun recvar ()
        (setvar "CMDECHO" cmd_ini)
        (setvar "FLATLAND" fla_ini)
        (setvar "OSMODE" osm_ini)
        (setvar "ORTHOMODE" ort_ini)
        (setvar "PLINETYPE" plt_ini)
        (setvar "AUPREC" aup_ini)
        (setvar "UNITMODE" uni_ini)
        (setvar "LUNITS" lun_ini)
        (setvar "DIMZIN" diz_ini)
        (setvar "EDGEMODE" edg_ini)
        ) ;_ end_defun
        (command "layer"
             "make"
             "PMSFptwtxt-3dpoints"
             "COLOR"
             "1"
             ""
             ""
        ) ;_ end_command
     
        (setq w1_tagname
             (getstring
             "\n>>>...Enter Tag name of attribute...>>>: "
             ) ;_ end_getstring
        ) ;_ end_setq
        (setq *modelspace*
             (vla-get-modelspace
             (vla-get-activedocument (vlax-get-acad-object))
             ) ;_ end_vla-get-modelspace
        ) ;_ end_setq
     
        (setq txt (ssget '((0 . "INSERT"))))
        (setq letxt (sslength txt))
        (setq counter 0)
        (while (< counter letxt)
        (progn
            (w1 (ssname txt counter))
            (setq txtent (entget (ssname txt counter)))
            (setq txtx (car (cdr (assoc 10 txtent))))
            (setq txty (cadr (cdr (assoc 10 txtent))))
            (setq xyz (list txtx txty txtz))
            (command "layer" "set" "PMSFptwtxt-3dpoints" "")
            (command "point" xyz)
        ) ;_ end_progn
        (setq counter (1+ counter))
        ) ;_ end_while
    ;;;
        (recvar)
    ;;;
        (command "layer" "set" "0" "")
        (princ)
    ) ;_ end_defun
    (alert
        "Type PMSFptwtxt and press enter to run\n\n            *Author: Pedro Ferreira*"
    ) ;_ end_alert
    Last edited by wizman; 7th Nov 2008 at 07:59 pm. Reason: updated for numberp test and minor revision

  4. #4
    Junior Member
    Computer Details
    StuboJones's Computer Details
    Operating System:
    Windows XP
    Computer:
    Latitude E5410
    CPU:
    Intel i3
    Monitor:
    Laptop
    Using
    AutoCAD 2011
    Join Date
    Nov 2008
    Location
    London
    Posts
    13

    Default

    Registered forum members do not see this ad.

    Awesome! You have no idea how good you're gonna make me look
    Thanks Wizman.

Similar Threads

  1. Replies: 36
    Last Post: 8th May 2012, 05:33 pm
  2. Change Block Attribute base on Insertion Point
    By tptaylor in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 17th Sep 2008, 07:43 pm
  3. Block Attribute answers ability to change block Physical Attributes??
    By Kaidoz in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 19th Mar 2008, 10:25 pm
  4. using insertion point in block attribute
    By aamotox in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 21st Feb 2007, 09:07 pm
  5. Get x,y coordinates of blocks insertion point into attribute
    By tpatton10 in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 2nd Dec 2005, 02:11 pm

Bookmarks

Posting Permissions

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