Jump to content

Insert symbols to reflect attribute code


Recommended Posts

Posted

I have found an LISP routine that inserts a symbol from using the attribute settings of a point (POINT_CODE) and place them into the layers they are meant to be in. The (getvar "userr4") is used to scale our dwg for example, scale 1:200 would make the "userr4" be 0.2, this is how we scale our linework and symbols.

(defun pdetl (et etl)
 (setvar "cmdecho" 0)
 (if (and (= (cdr (assoc '0 etl)) "INSERT")
   (or (= "CIR" (strcase (substr (cdr (assoc '2 etl)) 1 3)))
       (= "$CIR" (strcase (substr (cdr (assoc '2 etl)) 1 4)))
       (= "GPT" (strcase (cdr (assoc '2 etl))))
       (= "POINT_CROSS" (strcase (cdr (assoc '2 etl))))
       (= "GULLY" (strcase (cdr (assoc '2 etl))))
   )
     )
   (progn
     (setq px 0.0
    py 0.0
    pz 0.0
    pnum ""
    pcode ""
    phgt ""
    phgt2 ""
     )
     (setq px (cadr (assoc '10 etl)))
     (setq py (caddr (assoc '10 etl)))
     (setq pz (cadddr (assoc '10 etl)))
     (setq phgt2 (rtos pz 2 2))
     (setq etl (entget (setq et (entnext et))))
     (while (/= (cdr (assoc '0 etl)) "SEQEND")
(cond ((= "POINT_NUMBER" (strcase (cdr (assoc '2 etl)))) (setq pnum (cdr (assoc '1 etl))))
      ((= "POINT_CODE" (strcase (cdr (assoc '2 etl)))) (setq pcode (cdr (assoc '1 etl))))
      ((= "POINT_HEIGHT" (strcase (cdr (assoc '2 etl)))) (setq phgt (cdr (assoc '1 etl))))
      (t nil)
)
(setq etl (entget (setq et (entnext et))))
     )
     T
   )
   nil
 )
)
(defun flr (x y) x)
(defun fll (x y) x)
(defun nodigits	(s)
 ;; function
 ;; returns a string s without any digits - leaves on alpha chars
 (setq	l (strlen s)
p 1
r ""
 )
 (while (<= p l)
   (setq c (substr s p 1))
   (if	(not (isdigit c))
     (setq r (strcat r c))
   )
   (setq p (1+ p))
 )
 r
)
(defun isdigit (c)
 (if c
   (and (<= (ascii c) 57) (>= (ascii c) 48))
   nil
 )
)
(defun c:ptsym ()
 ;; insert Symbols for Points
 (if (setq ss (ssget))
   (progn (setq u 0)
   (setq numss (sslength ss))
   (while (/= numss u)
     (setq etl (entget (setq et (ssname ss u))))
     (setq u (1+ u))
     (if (= (cdr (assoc '0 etl)) "INSERT")
       (progn (if (pdetl et etl)
		(progn (princ (flr pnum 6))
		       (princ "   ")
		       (setq pcode (strcase (nodigits pcode)))
		       (princ (flr pcode 10))
		       (princ "...")
		       (setq p1 (trans (LIST PX PY) 0 1))
		       (cond ((or (= pcode "TELE") (= pcode "TPIT"))
			      (progn (command "-layer" "m" "S-COMMS_INFO" "")
				     (command "insert" "pp" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((= pcode "EBOX")
			      (progn (command "-layer" "m" "S-ELEC_INFO" "")
				     (command "insert" "EBOX" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((= pcode "ELP")
			      (progn (command "-layer" "m" "S-ELEC_INFO" "")
				     (command "insert" "LIGHT" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((= pcode "EPIT")
			      (progn (command "-layer" "m" "S-ELEC_INFO" "")
				     (command "insert" "EPIT" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((or (= pcode "PP") (= pcode "EP"))
			      (progn (command "-layer" "m" "S-ELEC_INFO" "")
				     (command "insert" "PP" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((= pcode "GM")
			      (progn (command "-layer" "m" "S-GAS_INFO" "")
				     (command "insert" "GM" "s" (getvar "userr4") p1 "")
			      )
			     )
			     ((= pcode "GV")
			      (progn (command "-layer" "m" "S-GAS_INFO" "")
				     (command "insert" "GV" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "RWMH")
			      (progn (command "-layer" "m" "S-ROOFWATER_INFO" "")
				     (command "insert" "RWMH" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "SIO")
			      (progn (command "-layer" "m" "S-SEWER_INFO" "")
				     (command "insert" "SIO" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((or (= pcode "SMH") (= pcode "SM"))
			      (progn (command "-layer" "m" "S-SEWER_INFO" "")
				     (command "insert" "SMH" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "GT")
			      (progn (command "-layer" "m" "S-STORM_INFO" "")
				     (command "insert" "GT" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "KO")
			      (progn (command "-layer" "m" "S-STORM_INFO" "")
				     (command "insert" "BLOB" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "SWGT")
			      (progn (command "-layer" "m" "S-STORM_INFO" "")
				     (command "insert" "GRATE" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "SWIO")
			      (progn (command "-layer" "m" "S-STORM_INFO" "")
				     (command "insert" "SWIO" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "SWMH")
			      (progn (command "-layer" "m" "S-STORM_INFO" "")
				     (command "insert" "SWMH" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "TSP")
			      (progn (command "-layer" "m" "S-TRAFFIC_INFO" "")
				     (command "insert" "TRAF" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "UKN")
			      (progn (command "-layer" "m" "S-UNKNOWN_INFO" "")
				     (command "insert" "US " "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "UP")
			      (progn (command "-layer" "m" "S-UNKNOWN_INFO" "")
				     (command "insert" "UP" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "FH")
			      (progn (command "-layer" "m" "S-WATER_INFO" "")
				     (command "insert" "FH" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "TAP")
			      (progn (command "-layer" "m" "S-WATER_INFO" "")
				     (command "insert" "TAP" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "WM")
			      (progn (command "-layer" "m" "S-WATER_INFO" "")
				     (command "insert" "WM" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "WPIT")
			      (progn (command "-layer" "m" "S-WATER_INFO" "")
				     (command "insert" "WATER" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "WV")
			      (progn (command "-layer" "m" "S-WATER_INFO" "")
				     (command "insert" "WV" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "HOIST")
			      (progn (command "-layer" "m" "HOIST_INFO" "")
				     (command "insert" "CHOIST" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "AIRCON")
			      (progn (command "-layer" "m" "AIRCON_INFO" "")
				     (command "insert" "AIRCON" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((or (= pcode "BOL") (= pcode "BOLLARD"))
			      (progn (command "-layer" "m" "BOLLARD_INFO" "")
				     (command "insert" "BLOB" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "FL")
			      (progn (command "-layer" "m" "FLOOR_INFO" "")
				     (command "insert" "BLOB" "s" (getvar "userr4") p1 "")
			      )
			     )
				 ((= pcode "*TR")
			      (progn (command "-layer" "m" "TREE_INFO" "")
				     (command "insert" "TREE" "s" (getvar "userr4") p1 "")
			      )
			     )
		       )
		)
	      )
       )
     )
   )
   )
 )
 (princ)
)

 

open?id=1CIkOy5s0iarzUFkgdXQMh2pmTbLjkX6D

 

Now i am trying to get this routine to add text and scale trees not from "userr4" but part of the code. For example;

1. Insert a power pole symbol with the number next to the symbol. The text in the POINT_CODE attribute would look like "PP 123456".

open?id=1Xy9GxcJt_aVFSRD9eRvuZ8Xjm1991tIm

2. Insert a tree symbol and scale the tree to the spread of the tree and add the text next to the point. The text in the POINT_CODE attribute would look like "TR 0.2D 2H 2S" the "2S" would be the scale of being 2.0.

open?id=1O74ePdQbmqqH6DPA-YTBOt03HPUdOhAG

 

Does anyone use anything similar or have any idea on what path i should be trying to get this to work. I am currently using Autocad 2016. Thank you

Posted

Sounds like your using Civilcad or Magnet. Any way the tree part is the easy part you make a dynamic block with the the tree spread shape and the trunk as say a circle. then you can set the two independent of each other.

 

This is based around using CIV3D points but should give you all the answers for what you want.

; Dynamically insert a tree based on civ3D point description 
; By Alan H Sep 2016
; version 2 read a csv file for non Civ3D users

;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(defun LM:setdynpropvalue ( blk prp val )
   (setq prp (strcase prp))
   (vl-some
      '(lambda ( x )
           (if (= prp (strcase (vla-get-propertyname x)))
               (progn
                   (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                   (cond (val) (t))
               )
           )
       )
       (vlax-invoke blk 'getdynamicblockproperties)
   )
)

;; CSV -> List  -  Lee Mac
;; Parses a line from a CSV file into a list of cell values.
;; str - [str] string read from CSV file
;; sep - [str] CSV separator token
;; pos - [int] initial position index (always zero)

(defun LM:csv->lst ( str sep pos / s )
   (cond
       (   (not (setq pos (vl-string-search sep str pos)))
           (if (wcmatch str "\"*\"")
               (list (LM:csv-replacequotes (substr str 2 (- (strlen str) 2))))
               (list str)
           )
       )
       (   (or (wcmatch (setq s (substr str 1 pos)) "\"*[~\"]")
               (and (wcmatch s "~*[~\"]*") (= 1 (logand 1 pos)))
           )
           (LM:csv->lst str sep (+ pos 2))
       )
       (   (wcmatch s "\"*\"")
           (cons
               (LM:csv-replacequotes (substr str 2 (- pos 2)))
               (LM:csv->lst (substr str (+ pos 2)) sep 0)
           )
       )
       (   (cons s (LM:csv->lst (substr str (+ pos 2)) sep 0)))
   )
)

(defun dynamic_trees ( / obj obj2 raw inspt )

;(if (not LM:csv->lst)(load "ReadCSV-V1-3"))
;(if (not LM:setdynpropvalue)(load "set-dynamic-block-value"))

(setq layold (getvar "clayer"))

(if (not (tblsearch "LAYER" "EX_TREE"))
    (Command "-layer" "m" "EX_TREE" "c" 90 "EX_TREE" "LT" "Continuous" "EX_TREE" "")
    (setvar "clayer" "EX_TREE")
)

(setq ss (ssget "x" '((0 . "AECC_COGO_POINT"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq raw (vla-get-description obj))
(setq inspt (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'location))))

;RawDescription = "TR 5 1.5" replace tr as required add extra tree types also
; use space delimeted description - tree trunk spread
(if (wcmatch raw "TR*") 
(progn
(setq rawlist (LM:csv->lst raw " " 0))

(setq basedesc (nth 0 rawlist))
(setq spread (atof (nth 2 rawlist)))
(setq trunk (atof (nth 1 rawlist))) ; convert string

(if (= "TR" basedesc)
(progn
(command "-Insert" "TREEDYN" inspt 1 1 0)
(setq obj2 (vlax-ename->vla-object (entlast)))
(LM:setdynpropvalue obj2 "Trunk" trunk)
(LM:setdynpropvalue obj2 "Spread" spread)
) ;progn
) ; if
) ;progn
) ; if
) ; repeat

(setvar "clayer" layold)
(princ) ; exit quitely
) ;defun
(dynamic_trees)

 

Could you explain more how the points are being created as making the points with blocks when reducing is easier.

Posted

Hello BIGAL

 

Thank you for the tree code i will have to figure how to make a dynamic block and give this code a try.

 

Yes I am using Manget Office. When I export my job into Autocad, Magnet Office creates a point (as a dot) then creates a block with attributes over the top of the point as shown i the picture. I remove all the points with a LISP routine that I created and keep the block with the attributes as shown in the picture. I do not like the symbols that Magnet use because most of the time they do not work or look any good.

 

https://drive.google.com/open?id=1CIkOy5s0iarzUFkgdXQMh2pmTbLjkX6D - Point attribute

https://drive.google.com/open?id=1Xy9GxcJt_aVFSRD9eRvuZ8Xjm1991tIm - Power pole code

 

I could not get the picture to show when using IMG brackets so could only link the picture.

Posted

We are running Magnet now but the symbols are set during point reduction and we normally have no problems. I have some lisps delete Point_cross read a text file of layers resetting colour and line type, I leave the actual 3d point as just that an Autocad point so can turn of or on so we can check actual Z value but all line work is reset to be ZERO. Stuff like our trees are coded for size in field. We do layer renaming after the survey guys as it was easier via lisp as they have 20+ years of knowing codes so we just add EX_ to front of every layer plus some other prefixes. Ex_LIP is now different to LIP comparing existing to design.

 

We have two library sets one with layers prefixed with the numeric field code and the other alpha so we strip the numeric off the front also they are set in their ways.

 

Attach an image as a file I use a screen grabber.

treedyn.dwg

Posted
do not like the symbols that Magnet use

 

You need to go back a step and fix this problem, I am sure that if you import a Autocad dwg you can use the blocks as symbols in Magnet fixing the problem.

 

Asked the guys here and will do a bit more any way code is TR*S3 will auto scale the tree to a scale of 3.

Posted

Bigal, I have just imported all the symbols into Magent and the problem that I have is the text style I use in autocad is not supported in magnet so the text in the symbol is wrong and too big. I have fixed that making the text fit within the symbol so it look right in Magnet. Then I renamed the symbol that I used in autocad to the same name as the symbol that Magnet exports. I have created Attributes in the autocad symbols to match the same attribute name that is in Magnet so then I can now have the code display next to the symbol once in autocad automatically. I used a lisp file from Lee Mac site to redefine the symbols so everything works. With the tree codes I have to keep it the way I am currently doing so anyone that is checking the plan can check the details are right so I will have to find a way around that.

Posted

1 text style if its a Autocad SHX text style then find the equivalent in a TTF I am pretty sure magnet uses TTF, but you have to load onto your PC also. If your using say Isocp a stick type font check your windows True type fonts some are pretty close.

 

Unless you want to get real technical its stuff like the number 4 is closed or open. The decimal is at bottom or middle.

 

2 What is your code for the trees ?

 

3 What was the Autocad font ?

Posted

My code for trees are TR 0.2D 4H 4S

 

The autocad font that i use for the symbols are the survacad.shx

 

I created a font that makes the full stop show in the middle instead at the bottom for all the distances for the survey plans.

Posted

Changes for above, need lee-macs Parse.lsp as well so pulls the numeric out and leaves the D and S behind, can have a 3d tree if you want.

 

Still think the true type is the way to go can you post an image of the survacad.shx not sure if its copyrighted in any way.

 

I will try to find some time to post some code for you

 

 

(setq basedesc (nth 0 rawlist))
(setq spread (atof (nth 3 rawlist)))
(setq trunk (atof (nth 1 rawlist))) ; convert string

 

Need to use something like this to remove the D, H & S

 

;-------------------=={ Parse Numbers }==--------------------;;
;;                                                            ;;
;;  Parses a list of numerical values from a supplied string. ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;------------------------------------------------------------;;
;;  Returns:  List of numerical values found in string.       ;;
;;------------------------------------------------------------;;

(defun LM:ParseNumbers ( s )
 (
   (lambda ( l )
     (read
       (strcat "("
         (vl-list->string
           (mapcar
             (function
               (lambda ( a b c )
                 (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
                 )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
           )
         )
         ")"
       )
     )
   )
   (vl-string->list s)
 )
)

Posted

If your matching the font to a state land title requirement as happens here in VIC, then what is that font, Isocp, Iso3098B etc. You should be able to find a TTF that matches and problems will go away in Magnet and Autocad.

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