0 Members and 1 Guest are viewing this topic.
(defun nss:txt_pt_to_xrec ( pt_list / k x y z d);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function to create an xrecord entity from a text point list given as:;;; (name northing easting elevation decription);;; e.g.: ("3" "4957089.60950" "5568211.18416" "99.20000" "DH");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq k (car pt_list) ; The point name is the key y (atof (cadr pt_list)) ; The northing is the y x (atof (caddr pt_list)) ; The easting is the x z (atof (cadddr pt_list)) ; The elevation is the z d (last pt_list) ; The description ) (entmakex (list '(0 . "XRECORD") '(100 . "AcDbXrecord") (cons 2 k) (list 10 x y z) (cons 1 d) ) ));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun nss:txt_pts_to_dict ( pts_list / pt xrecs);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function to add a list of text point lists to the points dictionary. ;;; A list of text point lists looks like: ;;; (;;; ("1" "4957000.00000" "5568000.00000" "97.00000" "DH") ;;; ("2" "4957170.06183" "5568132.61079" "97.32800" "DH") ;;; ("3" "4957089.60950" "5568211.18416" "99.20000" "DH");;; );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq xrecs (mapcar '(lambda(x)(nss:txt_pt_to_xrec x)) pts_list)) (setq pts_list nil) (mapcar '(lambda(x)(nss:put_xrec_in_dict x (nss:ptdict))) xrecs));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nss:get_dict (dname parent_dict / dict);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function to get a dictionary by name from a given parent. A new dictionary;;; will be created if one cannot be found.;;; Input: dname <-- string name of dictionary to get or make;;; if it does not exist.;;; parent_dict <-- the dictionary entity the dictionary of interest;;; is in. Use (namedobjdict) to insert in the NOD.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;test if dictionary is already present in the main dictionary (and DEBUG (princ (strcat "\nDEBUG: nss:get_dict: getting " dname)) ) (if (not (setq dict (dictsearch parent_dict dname))) ;;if not found create a new one (progn (and DEBUG (princ "\nDEBUG: nss:get_dict: not found.") ) (setq dict (entmakex (list '(0 . "DICTIONARY") '(100 . "AcDbDictionary") ) ) ) ;and add it to the parent dictionary (and DEBUG (princ "\nDEBUG: nss:get_dict: adding dict.") ) (setq dict (dictadd parent_dict dname dict) ) );_ end progn (progn ;;else return its entity name (and DEBUG (princ "\nDEBUG: nss:get_dict: found dict.") ) (setq dict (cdr (assoc -1 dict))) );_ end else progn );_ end if);_ end defun;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object)))
If I remember correctly the conflict comes from using entmake and Code: [Select] (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object)))
(defun check_pt ( pt ) (and (listp pt) (>= (length pt) 3) (numberp (car pt)) (numberp (cadr pt)) (numberp (caddr pt)) )) (defun make_attr ( tag val ask pt_at lay / );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Simple test funtion to create an attribute entity using entmake.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (and (check_pt pt_at) (snvalid lay 0) (not (wcmatch tag "*[ ]*")) (/= tag "") (setq ent (entmake (list '(0 . "ATTDEF") (cons 8 lay) (cons 1 val) (cons 2 tag) (cons 3 ask) '(10 0 0 0) (cons 11 pt_at) '(40 . 2.5) '(70 . 0) '(74 . 2) ) ) ) ) ent);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun make_node ( pt_at lay / ent);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Simple test funtion to create a point entity using entmake;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (and (check_pt pt_at) (snvalid lay 0) (setq ent (entmake (list '( 0 . "POINT") (cons 8 lay) (cons 10 pt_at))) ) ) ent);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun make_block ( block_name base_pt / );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Simple test funtion to create a block entity;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;write block header (and (snvalid block_name 0) (check_pt base_pt) (entmake (list '(0 . "BLOCK") (cons 2 block_name) '(70 . 2) ; we will have non-const attr (cons '10 base_pt))) (make_node base_pt "GREG_POINT") (make_attr "ID" "id" "Enter id value: " (mapcar '+ base_pt '(2.5 0.0 0.0)) "GREG_ATTR" ) (setq block_name (entmake '((0 . "ENDBLK")))) ) block_name);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;