Jump to content

Recommended Posts

Posted

Hey guys,


I got a friend of mine to create a lisp program some time back which has been working fine up to now. Unfortunately he passed away a few years back so i cant get him to fix it.

 

It reads the attributes from a block and draws a 3d string to those invert levels in the attributes then writes to the attributes and updates the grade and pipe length.

The problem is now the block is inserted into a mleader and the only way to read and write to it is by exploding the mleader.

Can this lisp be modified to work with the mleader and block within it instead of exploding it ?

BTW Appreciate any help as I am not much good at lisp and only a beginner. Sorry.

Posted

Thanks Bigal.

It wouldn't let me yesterday but i'll try again.

22 hours ago, AlexS said:

Hey guys,


I got a friend of mine to create a lisp program some time back which has been working fine up to now. Unfortunately he passed away a few years back so i cant get him to fix it.

 

It reads the attributes from a block and draws a 3d string to those invert levels in the attributes then writes to the attributes and updates the grade and pipe length.

The problem is now the block is inserted into a mleader and the only way to read and write to it is by exploding the mleader.

Can this lisp be modified to work with the mleader and block within it instead of exploding it ?

BTW Appreciate any help as I am not much good at lisp and only a beginner. Sorry.

 

Posted

Here they are.... Sorry

If you explode the info box then the lisp works though not when all together.

 

Thanks for any help in advance

Pipe3D.LSP SAMPLE.dwg

Posted (edited)

If you use Nentsel can read the values in the block. Struggle to understand the rest of the task. Understand grade and length use.

 

(setq blk (nentsel "\nPick block"))
(setq vals (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 302)) (entget (car blk)))))
(princ vals)

("LEADER{" "9.80" "150" "xxx" "00.0" "9.21" "")

 

Edited by BIGAL
Posted

Thanks Bigal,
So can this be incorporated into the lisp routine so it reads the invert levels from the block, creates the 3d string to those levels, then rewrites the grade and pipe length to the block? in the script.

Regards Alex
 

Posted

INSTRUCTIONS

 

Thought I'd write this to clarify what I mean 😀

 

If you open the Sample.dwg and explode the leader so the block is separated from the mleader then this lisp will work fine.

 

Then use Appload and load the pipe3d.lsp and type pipe3d to run it.

It will prompt you to select the upstream end of the pipe and please select the top of the red line.

It will then prompt to select the pipe info block.

it will then read the upstream invert level from the pipe info block and the downstream invert level and draw a 3d line over the top of the red line (to these invert levels).
then it will update the block and add the pipe length and pipe grade and done 😀

 

The lisp routine works fine though the only problem i have is i have to explode the mleader from the block to do this.

Can this routing be amended to do this without exploding the mleader from the block ?

 

Appreciate any help i can get.

 

Regards Alex

 

Posted

Give this a try. The get property was the secret.

; https://www.cadtutor.net/forum/topic/96175-mleader-with-block-and-attributes/#comment-662196
; read and update a mleader block attributes 
; By AlanH Feb 2025

(defun c:blkgr ( / 10s blkent end grade il1 il2 len oldsnap start z)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(setq blkent (car (entsel "\nPick leader ")))


(setq il1 (atof  (getpropertyvalue blkent "USIL~BlockAttribute")))
(setq il2 (atof  (getpropertyvalue blkent "DSIL~BlockAttribute")))

(setq 10s (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10))(entget blkent))))
(setq pt (nth 2 10s))

(setq obj (vlax-ename->vla-object (ssname (ssget pt '((0 . "LINE"))) 0)))

(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(setq len (vlax-get obj 'length))
(setq start (list (car start)(cadr start) il1))
(setq end (list (car end)(cadr end) il2))
(command "3dline" start end "")

(setq z (- il2 il1))
(setq grade (strcat (rtos (* 100. (/ z len)) 2 1) " %"))

(setpropertyvalue blkent "GR~BlockAttribute" grade)
(setpropertyvalue blkent "LENGTH~BlockAttribute" (rtos len 2 2))

(setvar 'osmode oldsnap)
(princ)
)
(c:blkgr)

 

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