We have a need to convert 2D blocks to 3D to build a new surface. Our old spot elevations were comprised of two blocks, one called spotp which was the actual point on the drawing where the desired elevation was and one called spotel that has the attribute for the elevation enclosed in an ellipse, a line joins the two. I would like the program to prompt you to select the spotel block with the attribute, extract the elevation string, then prompt you to pick one or more spotp blocks and change the elevation of those to the value of the attribute extracted from the selected spotel block.
I already have a program that takes blocks with z elevation and creates points with the assigned elevation so once we elevate the spotp blocks we can use it to create point data to build the new surface.
Thanks
Solved! Go to Solution.
Solved by Shneuph. Go to Solution.
@jimperson66 wrote:I would like the program to prompt you to select the spotel block with the attribute, extract the elevation string, then prompt you to pick one or more spotp blocks and change the elevation of those to the value of the attribute extracted from the selected spotel block.
Thanks
Does SPOTEL have more than one attribute? If so what is the attribute tag of the elevation attribute?
This works pretty well.. It has NO error checking so you have to make sure you select the correct elements (the blocks). It assumes that the SPOTL block has only 1 attribute, a string value that translates to a real number.
(Defun C:SLBELtoSPB ( / SpotL SpotP SPPosition Elevation) (vl-load-com) (setq SpotL (vlax-ename->vla-object (car (entsel "\nSelect SpotL Block: "))) SpotP (vlax-ename->vla-object (car (entsel "\nSelect SpotP Block: "))) SPPosition (vlax-variant-value (vla-get-insertionpoint spotp)) Elevation (atof (vla-get-textstring (car (vlax-safearray->list (vlax-variant-value (vla-getattributes spotl)))))) );setq (vlax-safearray-put-element SPPosition 2 Elevation) (vla-put-insertionpoint SpotP (vlax-make-variant SPPosition)) (princ (strcat "\nElevation: " elevation " put to block SpotP")) (princ) );defun
EDIT:
" then prompt you to pick one or more spotp blocks"
My bad... I'll have to change this around a bit..
Try this...
(Defun TempError (message /) (if (not (or (= message "Function cancelled") (wcmatch message "bad argument type:*") );or );not (princ (strcat "\nError: " message));print message );if (setq *error* backuperror) (princ) );defun (Defun C:SLBELtoSPB ( / SpotL SpotP SPPosition Elevation) (vl-load-com) (setq backuperror *error*) (setq *error* TempError) (setq SpotL (vlax-ename->vla-object (car (entsel "\nSelect SpotL Block: "))) Elevation (atof (vla-get-textstring (car (vlax-safearray->list (vlax-variant-value (vla-getattributes spotl)))))) );setq (while (setq SpotP (vlax-ename->vla-object (car (entsel "\nSelect SpotP Block: ")))) (setq SPPosition (vlax-variant-value (vla-get-insertionpoint spotp))) (vlax-safearray-put-element SPPosition 2 Elevation) (vla-put-insertionpoint SpotP (vlax-make-variant SPPosition)) (princ (strcat "\nElevation: " (rtos elevation) " put to block SpotP")) );while (setq *error* backuperror) (princ) );defun
Hi jimperson,
Give the following a try:
(defun c:test ( / ss1 ss2 elv ent ins i ) (if (and (setq ss1 (ssget "_+.:S:E" '((0 . "INSERT") (2 . "spotel") (66 . 1)))) (setq elv (distof (cdr (assoc 1 (entget (entnext (ssname ss1 0))))))) (setq ss2 (ssget "_:L" '((0 . "INSERT") (2 . "spotp")))) ) (repeat (setq i (sslength ss2)) (setq ent (entget (ssname ss2 (setq i (1- i)))) ins (cdr (assoc 10 ent)) ) (entmod (subst (list 10 (car ins) (cadr ins) elv) (assoc 10 ent) ent)) ) ) (princ) )
It will prompt for selection of the 'spotel' block, then multiple 'spotp' blocks, moving such blocks to the elevation specified by the attribute in the 'spotel' block.
Since you haven't given the tag name of the elevation attribute, I assume that it is the first attribute in the spotel block.
Hope this helps,
Lee