Jump to content

Need help to create labeling LISP


hkamal

Recommended Posts

(defun c:mnum ()
  (setvar "osmode" 0)
  (setq	i    (getint "\n Value to start with ---->")
	name (getstring "\n Sewer Name ----->")
	p    0
	a    0
	poi  '()
	poi1 '()
	pn   '()
  )
  (while (= a 0)
    (setq poi (cdr (assoc 10 (entget (car (entsel))))))
    (if	(> p 0)
      (progn

	(IF (and (>= (ANGLE POI POI1) (/ 11 7))
		 (<= (ANGLE POI POI1) (/ 33 7))
	    )
	  (SETQ MH "MH")
	  (SETQ MH "MH")
	)
	(IF (and (>= (ANGLE POI POI1) (/ 11 7))
		 (<= (ANGLE POI POI1) (/ 33 7))
	    )
	  (SETQ pn poi)
	  (SETQ pn poi1)
	)
	(IF (and (>= (ANGLE POI POI1) (/ 22 7))
		 (<= (ANGLE POI POI1) (/ 33 7))
	    )
	  (SETQ PN POI)
	)
	(command "-layer" "s" "sewer_manh" "")
	(command "-insert"
		 MH
		 poi
		 ""
		 ""
		 POI1
		 (strcat "MH" (rtos (+ i p) 2 0))
	)
	(command "-layer" "s" "sewer" "")
	(command "line" poi poi1 "")
	(command "-layer" "s" "SEWER NAME" "")
	(command "-insert"
		 "sewer name"
		 (list (/ (+ (car poi) (car poi1)) 2)
		       (/ (+ (cadr poi) (cadr poi1)) 2)
		 )
		 ""
		 ""
		 pn
		 name
	)
      )
    )
    (setq poi1 poi)
    (setq p (+ p 1))
  )
)

Hello 
I want to create a labeling lisp based on this code, this code was constructed in 2003 and it doesn't work on AutoCAD 2020 

Steps that lisp will do 
1- Asking for starting number for MNH 
2- Asking for the name of the pipe Line name (examples: K , K-1 , K-1-22)
3- Clicking on the line so the lisp will draw a block with MNH-# and MNH-#+1 at the ends of the line and putting the Line name in the middle 
After that just clicking on the lines and the sequence will repeat 
Note : Common issue I think duplicating the MNH blocks and naming numbers at the connection ends when clicking on the next line


 

Link to comment
Share on other sites

As the lisp doesn't create or import the blocks it inserts I'm assuming they're already in the drawing by way of a default template drawing. 

It would need to be attached before we could attempt to debug the lisp. 

	(IF (and (>= (ANGLE POI POI1) (/ 11 7))
		 (<= (ANGLE POI POI1) (/ 33 7))
	    )
	  (SETQ MH "MH")
	  (SETQ MH "MH")
	)

sets global variable  MH to the string "MH" whether the if statement is True or not then

	(command "-insert"
		 MH

attempts to insert a block MH which is actually defined as a string.

 

I find it hard to believe this code ever worked. Lisp hasn't changed that much. 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

I haven't looked at your code, but where and how doesn't it work? Does it get to a point and stop with or without an error, does it run all the way through and do nothing?

Link to comment
Share on other sites

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