Author Topic: Requesting a AUTOLEVEL TAG  (Read 5265 times)

0 Members and 1 Guest are viewing this topic.

teakoaktree

  • Guest
Requesting a AUTOLEVEL TAG
« on: November 18, 2011, 04:15:09 AM »
hi all ... im new to swamp & i was hoping someone could help me

pls. bear with me if its bit lengthy ...

i have attached a zip file that contain 2 drawing files
1. sample drawing.dwg
2. autolevels.dwg

once you've open the 1st item you will notice that the way the elevation was drawn was around the main "plan" similarly all the attribute LEVEL tag's are placed to it.

i've found this "autolevels.dwg" tag from another site, only trouble is it is relative to the "ucs/world" only and i have tried rotating it but it does not allow me to do so.
 
i was hoping for someone could help alter it by having some kind of a "marker" to the tag's base in which the marker can be placed at a specific location and it will stay there to become the 0.0 mark and increment from there when user move the "tag" itself.

think of it like a "Ship anchored in the ocean"

anchor = represent the marker @ 0 level
ship     = represent the level tag that when moved (vertically/ horizontally) its automatically updated

so if i copy the "(ship+anchor=one set)" and place it someplace in the drawing it will act on its own without affecting other "(ship+anchor)" like a shipyard or in a marina.

i hope im making sense :)

;;--------------
i was hoping the resulting "level tag" can be tailor similar to the sample dwg eg;    "CH = 3000"    (the unit is in mm)
;;--------------

thank you all very much for your patience and help

regards,
tot -- is using win xp/ autocad r2009
« Last Edit: November 18, 2011, 04:43:38 AM by teakoaktree »

teakoaktree

  • Guest
Re: Requesting a AUTOLEVEL TAG
« Reply #1 on: November 18, 2011, 04:43:58 AM »
oops .. mods pls. help to transfer to proper forum ... sorry :(

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Requesting a AUTOLEVEL TAG
« Reply #2 on: November 18, 2011, 09:34:46 AM »
Welcome to the Swamp.   8-)

A quick look and the Auto tags are dynamic blocks. I don't use them but many people here do so maybe one of them will help you design your own Elevation tag.

I'll take a quick look to see if there are any already here.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Requesting a AUTOLEVEL TAG
« Reply #3 on: November 18, 2011, 09:40:06 AM »
OK, here is some homework for you.  :-)
Elevation Tags
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Requesting a AUTOLEVEL TAG
« Reply #4 on: November 18, 2011, 09:45:12 AM »
Sorry for jumping in off subject but never knew you could search a site like with google.
Thanks CAB

mkweaver

  • Bull Frog
  • Posts: 352
Re: Requesting a AUTOLEVEL TAG
« Reply #5 on: November 18, 2011, 10:09:43 AM »
This should do what you want - or at least show you how.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Requesting a AUTOLEVEL TAG
« Reply #6 on: November 18, 2011, 11:04:37 AM »
Sorry for jumping in off subject but never knew you could search a site like with google.
Thanks CAB
You're quiet welcome Jeff.
It's a powerful search tool.   8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Requesting a AUTOLEVEL TAG
« Reply #7 on: November 18, 2011, 12:49:51 PM »
I've once helped OP on AUGI with the same request... Still my final conclusion is that this ELEVATION DYNAMIC BLOCK is only useful for UCS that is parallel to WCS... Maybe you've found exactly this on www : Topic on AUGI

I've already helped as much as I could then... Why don't you rotate your elevations/sections to be aligned with WCS, then you could use these blocks without any problems...

Sincerely, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mkweaver

  • Bull Frog
  • Posts: 352
Re: Requesting a AUTOLEVEL TAG
« Reply #8 on: November 18, 2011, 02:18:35 PM »
Marco,
My preference is to do my sections and elevations the same way OP has them - it makes it very easy to project points off the plan.

The block I posted works.  It's not quite automatic, but nearly, and works regardless of the UCS.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Requesting a AUTOLEVEL TAG
« Reply #9 on: November 18, 2011, 03:21:43 PM »
I saw your *.dwg... I am not familiar how it works, but one that I have checked from AUGI looks fine to me... Main problem then was that it uses field code with formula to obtain coordinates for elevations only in co-relation to WCS. I've modified original lsp code for automatic updating so that elevation block changes its value in reference to UCS that is parallel to WCS (relevant is value of Y coordinate - for elevation version of dynamic block and Z coordinate - for planar version of dynamic block of point obtained according to insertion point of block in WCS and current UCS that must be parallel to WCS - coordinates of UCS origin point)... This is why in my final code I created 2 new commands "UM" for moving UCS and automatically updating all dynamic blocks values and "BM" for moving single dynamic block that will automatically update its field value according to current UCS that as I said must be parallel to WCS...

All this is because these blocks have fields with formula for reading attribute values and automatic computation, and I think this is exactly what OP wanted - to have blocks that will behave according to their insertion point in relation with UCS origin...
Does this have sense, its on user to find out... If I am to use these blocks I would rotate my elevations and sections to be horizontal and use "UM" command to update all blocks and for single manipulation use "BM" for fine tuning and final modifications. I am sure this is much faster then if I am to insert blocks and do calculation manually witch then could be if not careful even wrong...

In addition to this, someone can make command "UMB" that will operate on UCS and update only selected dynamic blocks if these elevations and sections have different Y coordinate origins - are up-down to each other. For plan projections the same is to be processed, only this means that they should have different elevations Z coordinates of entities that are drawn so when dynamic block is associated to some point on plan projection it reads its Z value according to UCS origin point...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Requesting a AUTOLEVEL TAG
« Reply #10 on: November 18, 2011, 03:51:30 PM »
Here, I've created "UMB" and "BBM" commands also, and this version updates values of blocks if drawing is drawn in centimeters like architect projects usually are, and values of blocks are in meters and in centimeters - 2 digits behind "." delimiter...
I also attached *.dwg with dynamic blocks...

Code: [Select]
;;;-----------------------------------------------------------------------
;;; Makro     : AF2LB (Attach field to Level block)
;;; Version   : v1.0
;;; Date      : 05.11.2006
;;; Version   : AutoCAD 2006 / 2007
;;; Author    : Muharrem Kocyigit
;;;-----------------------------------------------------------------------
(setq glv:BlkName "Dyn-LEVEL-TR")
(setq glv:BlkATAG "LEVEL"       )
;;;-----------------------------------------------------------------------
(defun AF2LB   ( ss / e obj InsPt objAttribut ObjID FStr YVal PrFix n k
                 len x str ObjAttList lstDynProp DynID DynVal PtIndex ValOfPt
                 uorg uorgg)
(vl-load-com)
(setq uorg (getvar 'ucsorg))
  (if (/= ss nil)
    (progn
      (setq n  0 )

      (while (< n (sslength ss))

        (setq e   (ssname ss n))
        (setq obj (vlax-ename->vla-object e))

        (if (And (= (vla-get-ObjectName    obj) "AcDbBlockReference")
                 (= (vla-get-HasAttributes obj) :vlax-true) )

          (if    (= (vla-get-EffectiveName obj) glv:BlkName) (progn

            (setq ObjID (vla-get-ObjectID       obj)
                  InsPt (vla-get-InsertionPoint obj)
            )

            (setq InsPt
              (vlax-safearray->list (vlax-variant-value Inspt))
            )

            (setq InsPt (apply 'mapcar (cons '- (list InsPt uorg))))

            (if (= (vla-get-IsDynamicBlock obj) :vlax-true) (progn
             
             ;;; properties
           
            (setq lstDynProp
              (vlax-safearray->list
                (vlax-variant-value (vla-GetDynamicBlockProperties obj))
              )
            )
            (foreach x lstDynProp
              (if (member (vla-get-PropertyName x) (list "Visibility"))(progn
                (setq DynID  (vla-get-PropertyName x))
                (setq DynVal (vlax-variant-value (vla-get-Value x)) )
              )) ; end progn, if
            ) ; end forEach

            (cond
              ((member DynVal (list "Y1" "Y2" "Y3" "Y4"
                                    "Y5" "Y6" "Y7" "Y8" ))
                (setq ValOfPt (nth 1 InsPt) PtIndex 2) 
              )
              ((member DynVal (list "Z1" "Z2" "Z3" "Z4"))
                (setq ValOfPt (nth 2 InsPt) PtIndex 4) 
              )
              (T (setq ValOfPt (nth 1 InsPt) PtIndex 2))
            ) ; end cond

          )) ; end progn, if DynamicBlock

          ;;; Check Y-Value or Z-Value of point

          (setq str
            (cond
              ((> ValOfPt 0.0) "+"   )
              ((= ValOfPt 0.0) "%%P" )
              ((< ValOfPt 0.0) ""    )
              (T               ""    )
            )
          )

          ;;; Define Praefix

          (setq PrFix (strcat "%ps[" str ",]"))
          (setq YVal  (strcat "%<\\AcObjProp Object(%<\\_ObjId "
                              (itoa ObjID)
                              ">%).InsertionPoint>%"
          ))
          (setq uorgg (strcat "%<\\AcVar.17.0 Lisp.uorg>%"))
          (setq FStr (strcat "%<\\AcExpr (%<\\AcExpr (" YVal "-" uorgg ")>%" "/" "100" ") "
                             "\\f \"" "%lu2"
                             "%pt" (itoa PtIndex)
                             "%pr2" "%ds44" PrFix "\">%"
          ))

          ;;; Get Attribut of Block

          (setq objAttList
            (vlax-safearray->list
              (vlax-variant-value (vla-GetAttributes obj)
            )
          ))

          (setq k 0 len (length objAttList) )

          (while (< k len )
            (if (= (vla-get-TagString (setq x (nth k objAttList)))
                   glv:BlkATAG )
             (setq objAttribut x  k len )
            )
            (setq k (1+ k))
          )

          (if objAttribut (progn

            (vla-put-TextString objAttribut FStr )
            (vla-update objAttribut )

             ;;; Update Field Value with command

            (SetVar "CmdEcho" 0)
            (VL-CmdF "_.UpdateField" e "")
            (SetVar "CmdEcho" 1)

          )) ;; end progn, if
        ) ; end if
      )) ; end progn, if BLOCK + Attribut

      (setq n (1+ n))

    ) ; end while
  )) ; end progn, if

  (princ)
)
;;;-----------------------------------------------------------------------
(princ "\nAF2LB (Attach field to Level block) loaded ...")
(princ)

;;;-----------------------------------------------------------------------
(princ "\nCOMMAND \"UM\" -> UCS MOVE AND AUTOMATICALLY UPDATE ALL \"Dyn-LEVEL-TR\"")
;;;-----------------------------------------------------------------------
(defun c:um ( / cmde sel k seln entbl entblA)
(vl-load-com)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 1)
(command "ucs" "m" pause)
(setq sel (ssget "X" (list (cons 0 "INSERT") (cons 100 "AcDbBlockReference") )))
(setq k -1)
(setq seln (sslength sel))
(setq seldynblcks (ssadd))
(repeat seln
(setq k (1+ k))
(setq entbl (ssname sel k))
(setq entblA (vlax-ename->vla-object entbl))
(if (eq (vlax-get-Property entblA 'EffectiveName) "Dyn-LEVEL-TR") (ssadd entbl seldynblcks))
)
(AF2LB seldynblcks)
(setvar 'cmdecho cmde)
(princ)
)

;;;-----------------------------------------------------------------------
(princ "\nCOMMAND \"BM\" -> MOVE SINGLE \"Dyn-LEVEL-TR\" AND AUTOMATICALLY UPDATE")
;;;-----------------------------------------------------------------------
(defun c:bm ( / cmde entbl entblA)
(vl-load-com)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 1)
(setq sel (ssget ":S" (list (cons 0 "INSERT") (cons 100 "AcDbBlockReference") )))
(setq entbl (ssname sel 0))
(setq entblA (vlax-ename->vla-object entbl))
(if (eq (vlax-get-Property entblA 'EffectiveName) "Dyn-LEVEL-TR") () (progn (prompt "\nYou haven't selected block \"Dyn-LEVEL-TR\", please select correct block again with \"BM\" command function") (textscr) (command pause) (exit)))
(command "move" sel "" pause pause)
(AF2LB sel)
(setvar 'cmdecho cmde)
(princ)
)

;;;-----------------------------------------------------------------------
(princ "\nCOMMAND \"UMB\" -> UCS MOVE AND AUTOMATICALLY UPDATE ONLY SELECTED \"Dyn-LEVEL-TR\"")
;;;-----------------------------------------------------------------------
(defun c:umb ( / cmde sel k seln entbl entblA)
(vl-load-com)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 1)
(command "ucs" "m" pause)
(setq sel (ssget (list (cons 0 "INSERT") (cons 100 "AcDbBlockReference") )))
(setq k -1)
(setq seln (sslength sel))
(setq seldynblcks (ssadd))
(repeat seln
(setq k (1+ k))
(setq entbl (ssname sel k))
(setq entblA (vlax-ename->vla-object entbl))
(if (eq (vlax-get-Property entblA 'EffectiveName) "Dyn-LEVEL-TR") (ssadd entbl seldynblcks))
)
(AF2LB seldynblcks)
(setvar 'cmdecho cmde)
(princ)
)

;;;-----------------------------------------------------------------------
(princ "\nCOMMAND \"BBM\" -> MOVE AND AUTOMATICALLY UPDATE ONLY SELECTED \"Dyn-LEVEL-TR\"")
;;;-----------------------------------------------------------------------
(defun c:bbm ( / cmde sel k seln entbl entblA)
(vl-load-com)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 1)
(setq sel (ssget (list (cons 0 "INSERT") (cons 100 "AcDbBlockReference") )))
(command "move" sel "" pause pause)
(setq k -1)
(setq seln (sslength sel))
(setq seldynblcks (ssadd))
(repeat seln
(setq k (1+ k))
(setq entbl (ssname sel k))
(setq entblA (vlax-ename->vla-object entbl))
(if (eq (vlax-get-Property entblA 'EffectiveName) "Dyn-LEVEL-TR") (ssadd entbl seldynblcks))
)
(AF2LB seldynblcks)
(setvar 'cmdecho cmde)
(princ)
)

(princ)
(textpage)
(princ)

M.R.
« Last Edit: November 18, 2011, 04:13:43 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mkweaver

  • Bull Frog
  • Posts: 352
Re: Requesting a AUTOLEVEL TAG
« Reply #11 on: November 19, 2011, 12:51:28 AM »
Marco,
The block I posted is a dynamic block with a field in the attribute.  Simply insert the block at the zero elevation point, pick the block and stretch the grip up to the floor line.  This changes the length of a line in the block that is linked to the attribute and displays the length of the line in the attribute - this length will then be the elevation of the tag.  Try it, you'll like it, and no code required.

teakoaktree

  • Guest
Re: Requesting a AUTOLEVEL TAG
« Reply #12 on: November 19, 2011, 06:14:49 AM »
guys ...  :-)
;--
@cab - thanks for welcoming me, i did actually use the search here and went through your sugggested search, but all the related topics are all relative to the "world" ucs which similar to the sample that i provided herewith.
;--
@mkweaver - thanks for the sample, your idea is close to what im looking for, sadly im still have no idea how to compile a dynamic block and at the time being will need time to learn it.
i tried to put in text/numbers and combination of both ... but i cant see any changes or any update to the attrib i did refresh it everytime, 'am doing something not right? its very promising.
;--
@ribarm - hi, i checked the link you have provided and yes the idea of the op in that tread is similar to what im looking for.

              - like mkweaver had pointed out, the way we do drawings is like the sample i've provided, i know its a bit of a chalenge to make this tag to be able to placed it not only at WCS but like the way it is shown on the "sample.dwg" acting on its own. that's why i think the attribute need to have a base point (a marker) to act as the zero level for the tag incrimental value in millimeter if you may pls.
;--

thank you again for all the good suggestions pls. keep them commin ... :)

my apology for my poor english ... :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Requesting a AUTOLEVEL TAG
« Reply #13 on: November 19, 2011, 07:17:52 AM »
I guess this will not work for you?
http://www.theswamp.org/index.php?topic=27506.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Requesting a AUTOLEVEL TAG
« Reply #14 on: November 19, 2011, 08:28:50 AM »
Hey, CAB, your intervention was excellent... I am just posting now variant for centimeters - this is how I work...
Anchor point that you were talking about is origin of new UCS that can be also rotated - its now applicable to your example teakoaktree... If you want in millimeters, then copy code from first post that CAB pointed with link :

Code: [Select]
;;  Dynamic block field update to elevation based on the y-axis
;;  trans added by CAB to use UCS ILO WCS

;;;-----------------------------------------------------------------------
;;; Makro     : AF2LB (Attach field to Level block)
;;; Version   : v1.0
;;; Date      : 23.02.2006
;;; Version   : AutoCAD 2006 / 2007
;;; Author    : Muharrem Kocyigit
;;; Modified  : by CAB 02.18.2009 Changed to UCS ILO WCS & stripped Formatting
;;; Modified  : Hans Lammerts for Royal Haskonign 23.02.2009
;;; Changed to meters
;;; Draw line UCS function grdraw
;;; Function DNH
;;;-----------------------------------------------------------------------
(setq glv:BlkName "Dyn-LEVEL-TR")
(setq glv:BlkATAG "LEVEL"       )
;;;-----------------------------------------------------------------------
(defun c:DNH (/ sel e obj InsPt objAttribut ObjID FStr YVal PrFix ss n k
                 len x str ObjAttList lstDynProp DynID DynVal PtIndex ValOfPt)
  (vl-load-com)
  (prompt "\nDynamic height - Select Blocks to update Elevations.")
  (setq pt1 '(-10000000.0 0.0 0.0))
  (setq pt2 '(10000000.0 0.0 0.0))
  (grdraw pt1 pt2 6 1)
  (setq getucs (getvar "ucsname"))
  (prompt "\nCurrent UCS:")
  (prompt getucs)
 
  (if (setq ss (ssget))
    (progn
      (setq n  0 )
      (while (< n (sslength ss))

        (setq e   (ssname ss n))
        (setq obj (vlax-ename->vla-object e))

        (if (And (= (vla-get-ObjectName    obj) "AcDbBlockReference")
                 (= (vla-get-HasAttributes obj) :vlax-true) )

          (if    (= (vla-get-EffectiveName obj) glv:BlkName) (progn

            (setq ObjID (vla-get-ObjectID       obj)
                  ;;InsPt (vla-get-InsertionPoint obj)  ; CAB
                  InsPt (trans (vlax-get Obj 'InsertionPoint) (vlax-get Obj 'Normal) 1) ; OCS 2 UCS - CAB
            )

            ;(setq InsPt (vlax-safearray->list (vlax-variant-value Inspt)))  ; CAB
   
            (if (= (vla-get-IsDynamicBlock obj) :vlax-true)
              (progn
             
             ;; properties
           
            (setq lstDynProp
              (vlax-safearray->list
                (vlax-variant-value (vla-GetDynamicBlockProperties obj))
              )
            )
            (foreach x lstDynProp
              (if (member (vla-get-PropertyName x) (list "Visibility"))
                (progn
                (setq DynID  (vla-get-PropertyName x))
                (setq DynVal (vlax-variant-value (vla-get-Value x)) )
              )) ; end progn, if
            ) ; end forEach

            (cond
              ((member DynVal (list "Y1" "Y2" "Y3" "Y4"
                                    "Y5" "Y6" "Y7" "Y8" ))
                (setq ValOfPt (nth 1 InsPt) PtIndex 2) 
              )
              ((member DynVal (list "Z1" "Z2" "Z3" "Z4"))
                (setq ValOfPt (nth 2 InsPt) PtIndex 4) 
              )
              (T (setq ValOfPt (nth 1 InsPt) PtIndex 2))
            ) ; end cond

          )) ; end progn, if DynamicBlock

         ;;  Test Mod by CAB
    (princ ValOfPt)
(setq ValOfPt (/ ValOfPt 100.))
;   (princ "")
    (princ ValOfPt)
(setq ValOfPt (rtos ValOfPt 2 2))
;   (princ "")
    (princ ValOfPt)
(setq ValOfPt (atof ValOfPt))
            (princ "")
    (princ ValOfPt)        
        ; (setq ValOfPt (atoi (rtos (/ ValOfPt 100.) 2 2))) ; CAB rount to zero precision @ 0.49999 = 0

          ;;; Check Y-Value or Z-Value of point

          (setq str
            (cond
              ((> ValOfPt 0.0) "+"   )
              ((= ValOfPt 0.0) "%%P" )
              ((< ValOfPt 0.0) ""    )
              (T               ""    )
            )
          )

          ;;; Define Praefix
;|  CAB removed
          (setq PrFix (strcat "%ps[" str ",]"))
          (setq YVal  (strcat "%<\\AcObjProp Object(%<\\_ObjId "
                              (vl-princ-to-string ObjID)
                              ">%).InsertionPoint>%"
          ))
          (setq FStr (strcat "%<\\AcExpr (" YVal "/" "100" ") "
                             "\\f \"" "%lu2"
                             "%pt" (itoa PtIndex)
                             "%pr2" "%ds44" PrFix "\">%"
          ))
|;

(setq DZ (getvar "DIMZIN"))
(setvar "DIMZIN" 0)
(setq FStr  (strcat str (rtos ValOfPt 2 2)))
(setvar "DIMZIN" DZ)

          ;;; Get Attribut of Block

          (setq objAttList
            (vlax-safearray->list
              (vlax-variant-value (vla-GetAttributes obj)
            )
          ))

          (setq k 0 len (length objAttList) )

          (while (< k len )
            (if (= (vla-get-TagString (setq x (nth k objAttList)))
                   glv:BlkATAG )
             (setq objAttribut x  k len )
            )
            (setq k (1+ k))
          )

          (if objAttribut
            (progn

            (vla-put-TextString objAttribut FStr )
            (vla-update objAttribut )

             ;;; Update Field Value with command

            (SetVar "CmdEcho" 0)
            (VL-CmdF "_.UpdateField" e "")
            (SetVar "CmdEcho" 1)

          )) ;; end progn, if
        ) ; end if
      )) ; end progn, if BLOCK + Attribut

      (setq n (1+ n))

    ) ; end while
  )) ; end progn, if

  (princ)
)
;;;-----------------------------------------------------------------------
(princ "\n** Royal Haskoning 2009 **")
(princ "\n** command:DNH (Dynamic Height, attach field to Level block")
(princ "\n** function loaded ...")
(princ)

Thanks CAB, sincerely M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube