Jump to content

Using block attribute value to create 3D point


Recommended Posts

Posted

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

Posted

Cant tell this is my first time can you?

Running ACAD2009.

Posted

here's a modified version for blocks...'-)

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

Posted

Awesome! You have no idea how good you're gonna make me look :)

Thanks Wizman.

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