CHANGE LINE VERTEX Z BY APPLYING BLOCK ATTRIBUTE DEPTH

CHANGE LINE VERTEX Z BY APPLYING BLOCK ATTRIBUTE DEPTH

orourkestuart
Contributor Contributor
827 Views
10 Replies
Message 1 of 11

CHANGE LINE VERTEX Z BY APPLYING BLOCK ATTRIBUTE DEPTH

orourkestuart
Contributor
Contributor

Attached is a simple dwg of a services pit lid.

 

There are 4 "FEATURE_CROSS" blocks inserted for the survey pick-up points.

 

The blocks have an attribute called "CH_Depth" with a value of 0.99 (a default value from the field file).

 

I can't get to the point where I can access the CH_Depth and apply the -0.99 to the vertices of the associated lines, dropping the line by 0.99m to represent the "bottom" of the pit.

 

I usually 'reduce by depth' outside of AutoCAD vanilla, either in C3d or in 12d, but the client I'm working with only has access to AutoCAD vanilla licenses or BricsCAD.

 

There are a number of different kinds of point blocks with different named attributes for depths ("CH_Depth" "Depth" "INV_Depth" etc.), but if I have a solution for one I can hack up the rest myself.

 

Thx in advance.

0 Likes
Accepted solutions (1)
828 Views
10 Replies
Replies (10)
Message 2 of 11

3wood
Advisor
Advisor

You can try ALTEXT.

You need get a free registration and then use Formula in Example 17.

Message 3 of 11

orourkestuart
Contributor
Contributor

I think that's close enough for me to work from.

 

I'll need to make a number of changes. The attribute Z value is not the correct value. The point blocks all get dropped or raised after they've been inserted to comply with governmental reference marks. So it's the block's insertion point z that will be used in the calculation, not the text entry in the attributes.

 

But that's OK, it was the entmod entupd I couldn't work out.

 

Will post after I've amended.

 

TY

0 Likes
Message 4 of 11

3wood
Advisor
Advisor

I've amended it. Now it apply (Block insertion Z - the 6th attribute value) to nearby line vertex Z value.

ALTEXT15.gif

0 Likes
Message 5 of 11

orourkestuart
Contributor
Contributor

@3wood  that ALTEXT tool suite is cool, however it's not the ideal solution for chaining it through the existing LISP suite I have to work with. Totally appreciate the work though.

 

I need the solution to be a LISP I can add to the existing suite and then I'll add it to the start-up LISP I have for the surveyors to run when they're importing their field data.

 

I've taken some ideas from your formula, but I'm struggling with getting my LISP to entget after ssget'ing (I think) the lines associated with the survey point blocks.

 

This is what I wrote/hacked-up:

 

(defun c:LINEDROP ( / sel1 Numobj Blockname LISTART LIEND P1 P2 ZZ DDEPTH )

(varopen)

(setq sel1 (ssget "x" '((0 . "INSERT")(2 . "DIAG_CROSS_4"))))	


 (repeat (setq NumObj (sslength Sel1))
   	 (setq NumObj (1- NumObj) Blockname (ssname Sel1 NumObj))
 	 (setq DEPTH () CODE () )
  	 (GETATT Blockname)

 	 (SETQ DDEPTH (ATOF DEPTH))										;;;;TURN DEPTH CHARACTERS INTO A REAL NUMBER
	 (SETQ ZZ (ATOF Z))											;;;;TURN Z CHARACTERS FROM COORDBL INTO A REAL NUMBER
  


   (if 
	(and (= QL "B") (/= DEPTH "0.000") (/= DEPTH "0.001" )  (/= DEPTH "1.000e+308") (/= DEPTH " ") (/= DEPTH "0") (member CODE '("CSRB" "CUGB" "CULB" "DUGB" "DUGA" "EHVUGB" "ELVUGB" "ETVUGB" "EUGB" "FUGB" "FUUGB" "FSUGB" "GUGB" "GLPUGB" "GMPUGB" "GHPUGB" "GTPUGB" "IUGB" "OFUGB" "PUGB" "RUGB" "SUGB" "SUGA" "WRUGB" "UGOFB" "UUGB" "WUGB")) ) 

	(progn
	
	(CoordBL Blockname)											;;;;GO GET THE POINT BLOCKS INSERTION POINTS

	(SETQ LISTART 	(SSGET "x" (list '(0 . "LINE") '(-4 . "=,=,*") (cons 10 coord) )))			;;;;GO GET THE LINES AND EVALUATE THE "CONS 10" LINE START COORDINATE X,Y VALUE AGAINST THE BLOCK INSERTIONS
	(SETQ LIEND 	(ssget "x" (list '(0 . "LINE") '(-4 . "=,=,*") (cons 11 coord) )))			;;;;GO GET THE LINES AND EVALUATE THE "CONS 11" LINE END COORDINATE X,Y VALUE AGAINST THE BLOCK INSERTIONS

	(SETQ LIENTSTART (ENTGET (SSNAME LISTART 0))	)
	(SETQ LIENTEND	(ENTGET (SSNAME LIEND 0))	)

	(SETQ P1 (CDR (ASSOC 10 LIENTSTART)))
	(SETQ P2 (CDR (ASSOC 11 LIENTEND)))

       
        
	(if (AND (/= LIEND ()) (/= LISTART ()) )

        	(progn
		(entmod 	(subst 		(cons 10 (list (car P1) (cadr P1) (- ZZ DDEPTH))) 	(assoc 10 LIENTSTART) 	LIENTSTART)	)
	      	(entupd 	(cdr 	(assoc -1 LIENTSTART)	)	)

		(entmod		(subst 	(cons 11 (list (car P2) (cadr P2) (- ZZ DDEPTH))) (assoc 10 LIENTEND) LIENTEND))
	      	(entupd 	(cdr (assoc -1 LIENTEND)))	
		)
	)
	)
   )
 )

 (Varclose)
 (princ)
)

 

I keep getting a no selection set at the enget stage, but that's after the LISP adjusts a bunch of lines to start at 0,0,0. So I'm not sure why it would give me no ss but it changed some lines?

 

There's a number of referenced LISPs that I've zipped up along with the LINEDROP LISP and attached to this reply.

 

There's also a dwg with lines and point blocks in it as a test.

0 Likes
Message 6 of 11

orourkestuart
Contributor
Contributor

Thought I had the solution for a moment.....

 

There's an error in the definition of the value for the variable Z and therefore the math. I defined it as both the attribute z value and then again on the external call to "Coordbl".

 

I've attached the LISPs again with an altered call to "Coordbl2" and redefined the insertion point z value as variable z2 in that LISP.

 

This didn't fix the problem however.....

 

I'm guessing it's something to do with the lines not being selected as per the block insertion co-ordinate and that's giving me an empty ss? 

0 Likes
Message 7 of 11

CADaSchtroumpf
Advisor
Advisor
Accepted solution

Hi,

For try with your drawinng "2233.dwg"

(defun c:LINEDROP ( / sel_blk n dxf_blk pt_ins dxf_next lst_data sel_line dxf_line pt_start pt_end)
  (command "_.zoom" "_all")
  (setq sel_blk (ssget "_X" '((0 . "INSERT") (67 . 0) (8 . "SURVEY-POINTS") (66 . 1) (2 . "DIAG_CROSS_4"))))
  (cond
    (sel_blk
      (repeat (setq n (sslength sel_blk))
        (setq
          dxf_blk (entget (ssname sel_blk (setq n (1- n))))
          pt_ins (cdr (assoc 10 dxf_blk))
          dxf_next dxf_blk
        )
        (while (/= (cdr (assoc 0 (setq dxf_next (entget (entnext (cdar dxf_next)))))) "SEQEND")
          (if (eq (cdr (assoc 2 dxf_next)) "DEPTH")
            (setq lst_data (cons (cons pt_ins (cdr (assoc 1 dxf_next))) lst_data))
          )
        )
      )
      (mapcar
        '(lambda (x)
          (cond
            ((setq sel_line (ssget "_C" (mapcar '- (car x) '(0.05 0.05 0.0)) (mapcar '+ (car x) '(0.05 0.05 0.0)) '((0 . "LINE"))))
              (repeat (setq nb (sslength sel_line))
                (setq
                  dxf_line (entget (ssname sel_line (setq nb (1- nb))))
                  pt_start (cdr (assoc 10 dxf_line))
                  pt_end (cdr (assoc 11 dxf_line))
                )
                (if (equal (car x) pt_start 1E-08)
                  (entmod
                    (subst
                      (cons 10 (list (car pt_start) (cadr pt_start) (- (caddr pt_start) (atof (cdr x)))))
                      (assoc 10 dxf_line)
                      dxf_line
                    )
                  )
                )
                (if (equal (car x) pt_end 1E-08)
                  (entmod
                    (subst
                      (cons 11 (list (car pt_end) (cadr pt_end) (- (caddr pt_end) (atof (cdr x)))))
                      (assoc 11 dxf_line)
                      dxf_line
                    )
                  )
                )
              )
            )
          )
        )
        lst_data
      )
    )
  )
  (prin1)
)
Message 8 of 11

orourkestuart
Contributor
Contributor

Sorry I got the 'rona and have been offline.

 

Thanks for the reply, I'm going to test this now, will let you know how it goes.

0 Likes
Message 9 of 11

orourkestuart
Contributor
Contributor

@CADaSchtroumpf 

 

IS THIS LINE:

 

((setq sel_line (ssget "_C" (mapcar '- (car x) '(0.05 0.05 0.0)) (mapcar '+ (car x) '(0.05 0.05 0.0)) '((0 . "LINE"))))

 

like a "fuzz" parameter for +/- 50mm X and Y but exact Z value?

 

If it is, I can change 0.05 to 0.001 without any interference with the rest of the code?

0 Likes
Message 10 of 11

CADaSchtroumpf
Advisor
Advisor

Without testing, I think that you can change:

 

((setq sel_line (ssget "_C" (mapcar '- (car x) '(0.05 0.05 0.0)) (mapcar '+ (car x) '(0.05 0.05 0.0)) '((0 . "LINE"))))

to

((setq sel_line (ssget "_C" (mapcar '- (car x) '(0.001 0.001 0.001)) (mapcar '+ (car x) '(0.001 0.001 0.001)) '((0 . "LINE"))))

 withou interference, I have choicing 0.05 arbitrary...

Message 11 of 11

orourkestuart
Contributor
Contributor

@CADaSchtroumpf  TY for your code, got me out of a sticky situation 🙂

0 Likes