Hey All
this lisp is old and worked on AutoCAD 2007 but now it doesn't work on 2020
Please check it and here is a drawing to show what it does
Inputs is
number to start numbering
the text beside the number
Line name
If we can add a command for the arrow it will great
(defun c:mnum ()
(setvar "osmode" 0)
(setq i (getint "\n Value to start with ---->")
name (getstring "\n LINE 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 MANH "MANH")
(SETQ MANH "MANH")
)
(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" "MH LINE" "")
(command "-insert"
MANH
poi
""
""
POI1
(strcat "MH" (rtos (+ i p) 2 0))
)
(command "-layer" "s" "S-LINE" "")
(command "line" poi poi1 "")
(command "-layer" "s" "LINE NAME" "")
(command "-insert"
"LINE NAME"
(list (/ (+ (car poi) (car poi1)) 2)
(/ (+ (cadr poi) (cadr poi1)) 2)
)
""
""
pn
name
)
)
)
(setq poi1 poi)
(setq p (+ p 1))
)
)
Solved! Go to Solution.
Hey All
this lisp is old and worked on AutoCAD 2007 but now it doesn't work on 2020
Please check it and here is a drawing to show what it does
Inputs is
number to start numbering
the text beside the number
Line name
If we can add a command for the arrow it will great
(defun c:mnum ()
(setvar "osmode" 0)
(setq i (getint "\n Value to start with ---->")
name (getstring "\n LINE 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 MANH "MANH")
(SETQ MANH "MANH")
)
(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" "MH LINE" "")
(command "-insert"
MANH
poi
""
""
POI1
(strcat "MH" (rtos (+ i p) 2 0))
)
(command "-layer" "s" "S-LINE" "")
(command "line" poi poi1 "")
(command "-layer" "s" "LINE NAME" "")
(command "-insert"
"LINE NAME"
(list (/ (+ (car poi) (car poi1)) 2)
(/ (+ (cadr poi) (cadr poi1)) 2)
)
""
""
pn
name
)
)
)
(setq poi1 poi)
(setq p (+ p 1))
)
)
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by pbejse. Go to Solution.
First: Define "doesn't work." Does it not load? Does it load, but the command name isn't recognized? Does it accept the command, but nothing happens? If something happens, in what way(s) does it differ from what you expect? Are there any messages? Etc., etc.
First: Define "doesn't work." Does it not load? Does it load, but the command name isn't recognized? Does it accept the command, but nothing happens? If something happens, in what way(s) does it differ from what you expect? Are there any messages? Etc., etc.
It loads but when execute the command it gives error
Command: MNUM
Value to start with ---->0
Sewer Name ----->S
Select object:
Select object: ; error: bad argument type: lentityp nil
It loads but when execute the command it gives error
Command: MNUM
Value to start with ---->0
Sewer Name ----->S
Select object:
Select object: ; error: bad argument type: lentityp nil
@Anonymous wrote:
It loads but when execute the command it gives error
....
Select object: ; error: bad argument type: lentityp nil
That looks like the kind of error that would happen if you miss in picking something. After that happens, type in [or paste in] at the command line:
!poi
to see whether it found an entity to work with. If that returns a point coordinates list, then you didn't miss, and something else is going on.
@Anonymous wrote:
It loads but when execute the command it gives error
....
Select object: ; error: bad argument type: lentityp nil
That looks like the kind of error that would happen if you miss in picking something. After that happens, type in [or paste in] at the command line:
!poi
to see whether it found an entity to work with. If that returns a point coordinates list, then you didn't miss, and something else is going on.
Your loop is infinite because the variable "a" is always at 0
You have
(setq a 0)
(while (= a o) ....
But "a" not change, and if you not select an entitie you have: error: bad argument type: lentityp nil
It is poorly constructed. I'd rather see
(while (setq a (entsel))
(setq poi (cdr (assoc 10 (entget (car a)))))
Your loop is infinite because the variable "a" is always at 0
You have
(setq a 0)
(while (= a o) ....
But "a" not change, and if you not select an entitie you have: error: bad argument type: lentityp nil
It is poorly constructed. I'd rather see
(while (setq a (entsel))
(setq poi (cdr (assoc 10 (entget (car a)))))
Another thing, not related to the specific question:
I don't see anything that sets a value to the POI1 variable [except for '() , which is just nil ], so there will be trouble when a function wants to use it.
Another thing, not related to the specific question:
I don't see anything that sets a value to the POI1 variable [except for '() , which is just nil ], so there will be trouble when a function wants to use it.
@CADaSchtroumpf wrote:
Your loop is infinite because the variable "a" is always at 0
You have
(setq a 0)
(while (= a o) ....
But "a" not change....
That's a somewhat peculiar way to do something that is not uncommon, but is usually done without setting an unchanging variable:
(while T ....
which just keeps asking whatever it's looking for, as long as you want to keep going, requiring ESCape to end it. But I agree, there are better ways to do it, that can also be ended with Enter/space, or if you like when object selection is involved, with simply picking in empty space [emulating a way you can close Mtext].
@CADaSchtroumpf wrote:
Your loop is infinite because the variable "a" is always at 0
You have
(setq a 0)
(while (= a o) ....
But "a" not change....
That's a somewhat peculiar way to do something that is not uncommon, but is usually done without setting an unchanging variable:
(while T ....
which just keeps asking whatever it's looking for, as long as you want to keep going, requiring ESCape to end it. But I agree, there are better ways to do it, that can also be ended with Enter/space, or if you like when object selection is involved, with simply picking in empty space [emulating a way you can close Mtext].
it did return a coordinates so something else :S
it did return a coordinates so something else :S
Thank you guys but to be honest I'm not that good and the lisp was created in 2008 so is there solution for the code ?
or to construct a new easier lisp to do the labeling line name in the middle and the manhole sequence with circles at the ends of the line
Thank you guys but to be honest I'm not that good and the lisp was created in 2008 so is there solution for the code ?
or to construct a new easier lisp to do the labeling line name in the middle and the manhole sequence with circles at the ends of the line
@Anonymous wrote:
Thank you guys but to be honest I'm not that good and the lisp was created in 2008 so is there solution for the code ?
or to construct a new easier lisp to do the labeling line name in the middle and the manhole sequence with circles at the ends of the line
It should be easy, problem is understanding how it should work, knowing all conditions, and more drawing sample please.
@Anonymous wrote:
Thank you guys but to be honest I'm not that good and the lisp was created in 2008 so is there solution for the code ?
or to construct a new easier lisp to do the labeling line name in the middle and the manhole sequence with circles at the ends of the line
It should be easy, problem is understanding how it should work, knowing all conditions, and more drawing sample please.
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
4- after that just clicking on the lines and the sequence will repeat
Note : Common issue I think duplicating the MNH blocks and numbers at the connection ends
is that clear enough ?
MANH.dwg small scale how should it look and the full network to show the example of the work to try on
Ask me any question to help the process
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
4- after that just clicking on the lines and the sequence will repeat
Note : Common issue I think duplicating the MNH blocks and numbers at the connection ends
is that clear enough ?
MANH.dwg small scale how should it look and the full network to show the example of the work to try on
Ask me any question to help the process
@Anonymous wrote:
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
4- after that just clicking on the lines and the sequence will repeat
Most of the issues encountered with the OG lisp are the following
Here's what I did:
I'm guessing the first selection is a Manhole Block and the suceeding selections are LINES. [ modified the code to also accept a block for selection.
When any of these blocks are not found, the program will terminate
(tblsearch "BLOCK" "LINE NAME")
(tblsearch "BLOCK" "MANH")
Added the option to add the layers if it does not exist [ You can change this to suit your requirement ]
Note: I did not include the option for linetype.
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7))
(if (not (tblsearch "Layer" (Car itm)))
(entmake (append
(list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
)
(mapcar '(lambda (a b)
(cons a b)) '(2 62) itm))
)
)
)
Here's the modified code
(Defun C:mnum ( / rtd Base poi1 sel poi poi1 ang ent)
(defun rtd (a) (/ (* a 180.0) pi))
(setvar 'Attreq 1)
(setvar 'Attdia 0)
(setvar 'Insunits 6);<-- just an observation
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7))
(if (not (tblsearch "Layer" (Car itm)))
(entmake (append
(list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
)
(mapcar '(lambda (a b)
(cons a b)) '(2 62) itm))
)
)
)
(or MHNumber (setq MHNumber 0))
(or SNDef (setq SNDef "K"))
(setq MHNumber (cond
((getint (strcat "\nValue to start with"
(if MHNumber
(strcat " <" (itoa MHNumber) ">: ") ": " ))))
(MHNumber))
)
(if
(and
(tblsearch "BLOCK" "LINE NAME")
(tblsearch "BLOCK" "MANH")
(Setq Base (entsel "\nSelect Select first Manhole"))
(Setq poi1 (cdr (assoc 10 (setq ent (entget (car Base))))))
(setq SNDef (getstring (strcat "\nSewer Name ["
(cond (SPName) ("K")) "]: ")) SPName
(cond ((/= SNDef "") (strcase SNDef)) (SPName) ("K"))
)
)
(while
(progn
(setvar 'errno 0)
(setq sel (entsel "\nSelect Sewer Line: " ))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (= 'ename (type (car sel)))
(if (not (wcmatch (cdr (assoc 0 (setq ent (entget (car sel))))) "LINE,INSERT"))
(princ "\nInvalid Object Selected.")
(progn
(setq poi (cdr (assoc 10 ent)))
(setq ang (angle poi1 poi)
ang (if (and (> ang (/ pi 2)) (<= ang (* pi 1.5))
) (+ ang pi) ang ))
(setvar 'clayer "Sewer_Manh")
(command "-insert" "MANH" "non" poi "" "" "non" (rtd ang) (strcat "MH" (rtos MHNumber 2 0)))
(setvar 'clayer "S-LINE")
(command "line" "non" poi "non" poi1 "")
(setvar 'clayer "SEWER NAME")
(command "-insert" "LINE NAME"
(list (/ (+ (car poi) (car poi1)) 2)
(/ (+ (cadr poi) (cadr poi1)) 2)
) "" "" (rtd ang) SPName )
(setq poi1 poi MHNumber (1+ MHNumber))
(princ (strcat "\nNext Number is: " (itoa MHNumber)))
)
)
)
)
)
)
)(princ)
)
HTH
@Anonymous wrote:
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
4- after that just clicking on the lines and the sequence will repeat
Most of the issues encountered with the OG lisp are the following
Here's what I did:
I'm guessing the first selection is a Manhole Block and the suceeding selections are LINES. [ modified the code to also accept a block for selection.
When any of these blocks are not found, the program will terminate
(tblsearch "BLOCK" "LINE NAME")
(tblsearch "BLOCK" "MANH")
Added the option to add the layers if it does not exist [ You can change this to suit your requirement ]
Note: I did not include the option for linetype.
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7))
(if (not (tblsearch "Layer" (Car itm)))
(entmake (append
(list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
)
(mapcar '(lambda (a b)
(cons a b)) '(2 62) itm))
)
)
)
Here's the modified code
(Defun C:mnum ( / rtd Base poi1 sel poi poi1 ang ent)
(defun rtd (a) (/ (* a 180.0) pi))
(setvar 'Attreq 1)
(setvar 'Attdia 0)
(setvar 'Insunits 6);<-- just an observation
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7))
(if (not (tblsearch "Layer" (Car itm)))
(entmake (append
(list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
)
(mapcar '(lambda (a b)
(cons a b)) '(2 62) itm))
)
)
)
(or MHNumber (setq MHNumber 0))
(or SNDef (setq SNDef "K"))
(setq MHNumber (cond
((getint (strcat "\nValue to start with"
(if MHNumber
(strcat " <" (itoa MHNumber) ">: ") ": " ))))
(MHNumber))
)
(if
(and
(tblsearch "BLOCK" "LINE NAME")
(tblsearch "BLOCK" "MANH")
(Setq Base (entsel "\nSelect Select first Manhole"))
(Setq poi1 (cdr (assoc 10 (setq ent (entget (car Base))))))
(setq SNDef (getstring (strcat "\nSewer Name ["
(cond (SPName) ("K")) "]: ")) SPName
(cond ((/= SNDef "") (strcase SNDef)) (SPName) ("K"))
)
)
(while
(progn
(setvar 'errno 0)
(setq sel (entsel "\nSelect Sewer Line: " ))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (= 'ename (type (car sel)))
(if (not (wcmatch (cdr (assoc 0 (setq ent (entget (car sel))))) "LINE,INSERT"))
(princ "\nInvalid Object Selected.")
(progn
(setq poi (cdr (assoc 10 ent)))
(setq ang (angle poi1 poi)
ang (if (and (> ang (/ pi 2)) (<= ang (* pi 1.5))
) (+ ang pi) ang ))
(setvar 'clayer "Sewer_Manh")
(command "-insert" "MANH" "non" poi "" "" "non" (rtd ang) (strcat "MH" (rtos MHNumber 2 0)))
(setvar 'clayer "S-LINE")
(command "line" "non" poi "non" poi1 "")
(setvar 'clayer "SEWER NAME")
(command "-insert" "LINE NAME"
(list (/ (+ (car poi) (car poi1)) 2)
(/ (+ (cadr poi) (cadr poi1)) 2)
) "" "" (rtd ang) SPName )
(setq poi1 poi MHNumber (1+ MHNumber))
(princ (strcat "\nNext Number is: " (itoa MHNumber)))
)
)
)
)
)
)
)(princ)
)
HTH
Noticed one thing should a direction be checked 1st is there a rule lowest number is at low point ? Some sewer authorities will insist on this.
Noticed one thing should a direction be checked 1st is there a rule lowest number is at low point ? Some sewer authorities will insist on this.
I don't know how to thank you
Thank you very much it's amazing, can I ask you for another small lisp to draw an arrow with the opposite direction of the manholes taking the same block arrow in this drawing
I don't know how to thank you
Thank you very much it's amazing, can I ask you for another small lisp to draw an arrow with the opposite direction of the manholes taking the same block arrow in this drawing
"Rule lowest number is at low point" that is true when we design if it's a gravity network usually for sewer, we start from the inlet for treatment plant considering it our lowest point and the first manhole will be MH0/MH1
See this example DWG
The magenta line is our main
The green lines are sublines
"Rule lowest number is at low point" that is true when we design if it's a gravity network usually for sewer, we start from the inlet for treatment plant considering it our lowest point and the first manhole will be MH0/MH1
See this example DWG
The magenta line is our main
The green lines are sublines
Understand just mentioned if your auto labelling manholes need to check direction 1st.
Sewer and drainage https://civilsitedesign.com/
The software makes a network and does all labelling in one go.
Understand just mentioned if your auto labelling manholes need to check direction 1st.
Sewer and drainage https://civilsitedesign.com/
The software makes a network and does all labelling in one go.
@Anonymous wrote:
.. can I ask you for another small lisp to draw an arrow with the opposite direction of the manholes taking the same block arrow in this drawing
Here you go.
...
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7)("Arrow" 7)) ..
------------------------------------------------------------
(if
(and
(vl-every '(lambda (bn)
(tblsearch "BLOCK" bn)) '("LINE NAME" "MANH" "ARR"))..
------------------------------------------------------------
(setvar 'clayer "Arrow")
(command "-insert" "ARR" "non" mdpt "0.25" "0.25" (rtd ang))
...
HTH
Refer to attached lisp file [ mnum.lsp ]
@Anonymous wrote:
.. can I ask you for another small lisp to draw an arrow with the opposite direction of the manholes taking the same block arrow in this drawing
Here you go.
...
(foreach itm '(("SEWER NAME" 4)("S-LINE" 220) ("Sewer_Manh" 7)("Arrow" 7)) ..
------------------------------------------------------------
(if
(and
(vl-every '(lambda (bn)
(tblsearch "BLOCK" bn)) '("LINE NAME" "MANH" "ARR"))..
------------------------------------------------------------
(setvar 'clayer "Arrow")
(command "-insert" "ARR" "non" mdpt "0.25" "0.25" (rtd ang))
...
HTH
Refer to attached lisp file [ mnum.lsp ]
Hi,
I found this Lisp (mnum) which is used to number the manholes and to label the sewer pipeline, but I don't know what to write at the command line.
I tried mnum, it asks about the value to start with<1>, and when I type 1 it stops working.
Hi,
I found this Lisp (mnum) which is used to number the manholes and to label the sewer pipeline, but I don't know what to write at the command line.
I tried mnum, it asks about the value to start with<1>, and when I type 1 it stops working.
It's looking for the drawing to contain Block definition(s) of one or more of these names:
"LINE NAME" "MANH" "ARR"
Do you use those? If not, find them in the code and change to the name(s) you use.
It's looking for the drawing to contain Block definition(s) of one or more of these names:
"LINE NAME" "MANH" "ARR"
Do you use those? If not, find them in the code and change to the name(s) you use.
Can't find what you're looking for? Ask the community or share your knowledge.