Lisp to create Point with name Labeling

Lisp to create Point with name Labeling

m.galib
Explorer Explorer
3,236 Views
15 Replies
Message 1 of 16

Lisp to create Point with name Labeling

m.galib
Explorer
Explorer

Hey All,

 

Please i need a Lisp to create Point with name Labeling (example RE or CRB).

 

Thanks & Regards

 

0 Likes
Accepted solutions (1)
3,237 Views
15 Replies
Replies (15)
Message 2 of 16

ВeekeeCZ
Consultant
Consultant

Post some dwg sample to take a look at what you have in mind.

Is it a C3D label or just a text?

0 Likes
Message 3 of 16

m.galib
Explorer
Explorer

Capture.JPG

Lisp attached as it is..i think we just need to make some changes in lisp please check.

0 Likes
Message 4 of 16

Kent1Cooper
Consultant
Consultant

Did you attach the wrong file?  I don't see any relationship between your image and what the file does.  At the least, if I give it a starting number of 0, it doesn't put 0 at every location, but increments the numbers upward, so it won't make what you have in your image.  What would be the purpose of having them all be the same, when you therefore can't distinguish one point from another by its nearby Text?

 

And the code has some strange things in it, like asking you to supply a file name twice when it could ask only once, and the use of (* 1 pi) when plain pi would do [why multiply anything by 1?].  And something's wrong with the chart-making [not included in the image] -- it seems to do the first point's worth by itself, but not subsequent ones without some encouragement, by hitting Enter/space a few times and ignoring some error messages.  And that gets around to only the Text elements, but doesn't do the linework that the code looks like it's intended to draw.

 

Finally, I would recommend not using "I" as a command name, since it is the default command alias for INSERT.

 

More explanation, and a sample drawing file complete with all that the routine does, would help.

Kent Cooper, AIA
0 Likes
Message 5 of 16

calderg1000
Mentor
Mentor

Regards @m.galib 

It is not necessary to apply lisp, the Acad "FIND" command can do it.

 

calderg1000_0-1670533061788.png

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 6 of 16

devitg
Advisor
Advisor
Accepted solution

@m.galib  some like it?

devitg_0-1670543404978.png

(defun run ()
       (setq pll (getstring t "\n get name of new file (name.ext) :")) ; t so you can put spaces 
       (setq pl (open pll "w"))
       ;(setq e (getstring "\nget no. of first Point :"))
       ;(setq a (atoi e))
        (setq  a "GRB")
 
  (setq osmode (getvar 'osmode))
(setvar 'osmode 512)
  
       (while (setq p (getpoint "\nselect point :"))
       
;;;              (setq v1 (strcat "\n " (itoa a) "    "))
              (setq v1  (strcat "\n "  a "    "))     
              (setq d (polar p (/ (* 1 pi) 2) 0.5))    
              (command "layer" "m" "number" "c" "3" "" "")
              (command "text" "m" d 1.0 0.0 a)
              (setq num (entlast))
              (command "change" num "" layer "" number "") 
              
              (command "layer" "m" "point" "c" "1" "" "")
              (command "point" p)
              (setq pt (entlast))
              (command "change" pt "" layer "" point "")   
              (princ v1 pl)
              
              (setq x (car p))
              (setq x (rtos x 2 3)) 
              (setq x (strcat x "             "))
              (setq v2 x)
              (princ v2 pl)
              
              (setq y (cadr p))
              (setq y (rtos y 2 3))
              (setq y (strcat y "          "))
              (setq v3 y)
              (princ v3 pl)
;;;              (setq a (+ a 1))
       )
       (command "layer" "m" "txt" "c" "5" "" "")
       (close pl)
       (redraw)
       (princ)
)
; to get what is at pll
(startapp "notepad" pll)
;;
(defun c:pt+lb ()
       (run)
  
       ;(setq fil (getstring "\nget name of the file (name.ext) :"))
          
  (setq fil pll); you just have the file.
       (setq p1 (getpoint "select insertion point :"))
       (setq p2 (polar p1 0.0 30.0))
       (setq p3 (polar p1 0.0 100.0))
       (setq p4 (polar p1 (/ (* -1 pi) 2) 20.0))
       (setq p5 (polar p4 0.0 30.0))
       (setq p6 (polar p4 0.0 65.0))
       (setq p7 (polar p4 0.0 100.0))
       (setq p8 (polar p2 (/ (* -1 pi) 2) 10.0))
       (setq p9 (polar p8 0.0 35.0))
       (setq p10 (polar p8 0.0 70.0))
       (setq p11 (polar p8 (* -1 pi) 15.0))
       (setq p12 (polar p8 (/ pi 2) 5.0))
       (setq p13 (polar p8 (/ (* -1 pi) 2) 5.0))
       (setq p14 (polar p12 0.0 35.0))
       (setq p15 (polar p13 0.0 17.5))
       (setq p16 (polar p13 0.0 52.5))
       (setq p1- (polar p1 (/ (* -1 pi) 2) 2000000000.0))

       (command "text" "m" p11 3.0 0.0 "POINT NO.")
       (command "text" "m" p14 3.0 0.0 "COORDINATES")
       (command "text" "m" p15 3.0 0.0 "X")
       (command "text" "m" p16 3.0 0.0 "Y")
  ;new lines
(setq osmode (getvar 'osmode))
  (setvar 'osmode 0)
  ;new 
                       (command "line" p1 p4 "")
       (setq L14 (entlast))
       (command "line" p2 p8 p5 "")
       (setq L285 (entlast))
       (command "line" p9 p6 "")
       (setq L96 (entlast))
       (command "line" p3 p10 p7 "")
       (setq L3107 (entlast))
       (command "line" p1 p2 p3 "")
       (command "line" p8 p9 p10 "")
       (command "pline" p4 p5 p6 p7 "")
       (setq L4567 (entlast))

       (setq fill (open fil "r"))
       (read-line fill)
       (setq new ())
       (setq j 0.0)
       (setq p44 p4)
       (while (setq S (read-line fill))
              (setq pt (polar p44 (/ (* -1 pi) 2) (+ 5 j)))
              (setq pt1 (polar pt 0.0 15.0))
              (setq pt2 (polar pt 0.0 47.5))
              (setq pt3 (polar pt 0.0 82.5))
              
              (setq t1 (substr S 1 4))
              (setq t2 (substr S 5 16))
              (setq t3 (substr S 21 32))
              
              (command "text" "m" pt1 3.0 0.0 t1)
              (command "text" "m" pt2 3.0 0.0 t2)
              (command "text" "m" pt3 3.0 0.0 t3)
              
              (setq p4 (polar p4 (/ (* -1 pi) 2) 10.0))
              (setq p5 (polar p5 (/ (* -1 pi) 2) 10.0))
              (setq p6 (polar p6 (/ (* -1 pi) 2) 10.0))  
              (setq p7 (polar p7 (/ (* -1 pi) 2) 10.0))    
              
              (command "offset" (+ j 10.0) (list L4567 p4) p1- "")
              (setq new (entlast))
              
              (command "extend" new "" (list L14 P4) "")
              (command "extend" new "" (list L285 p5) "")
              (command "extend" new "" (list L96 p6) "")
              (command "extend" new "" (list L3107 p7) "")
              (setq j (+ j 10.0))
       )
       (close fill); to close fill

  
)

 

 

 

Message 7 of 16

Sea-Haven
Mentor
Mentor

Is this to do with say field surveys where a point file has XYZ & code, then you want to string them all together ?

 

So post a data file. After all this is the stuff CIVIL software does and more.

 

 

0 Likes
Message 8 of 16

m.galib
Explorer
Explorer

@devitgI’m thankful for your support and understanding what i need exactly. 

 

 

1-I have attached your DWG. with the additional  which needed .

2- Main DWG.  is attached where i have to create those points on every CYAN Lines and need to export them  in Excel or Notepad format ( The Lisp i have attached in previous does the same in some unknown format and its seems like Notepad).

3- The Lisp you attached here is giving error.

 

Thanks & Regards

    

0 Likes
Message 9 of 16

m.galib
Explorer
Explorer
@calderg1000, Thanks for kind reply, but am asking the help here to create point with labelling.
0 Likes
Message 10 of 16

m.galib
Explorer
Explorer

@Kent1Cooper Thank you so much for reply . Sorry I didn't explain myself well.

0 Likes
Message 11 of 16

m.galib
Explorer
Explorer
@Sea-Haven, thanks for your suggestion, Currently I'm using just AutoCad.
0 Likes
Message 12 of 16

Sea-Haven
Mentor
Mentor

So do you have a data points file that we could look at ?

Message 13 of 16

remon.shawky
Explorer
Explorer

Dears,

i see that lisp is very good 

but i need to select a group of points in one time then to create the table of the coordinates & label

not one by one  

0 Likes
Message 14 of 16

Sea-Haven
Mentor
Mentor

Post a dwg showing clearly the "POINT" to be labelled. With say a before and after of the point, yes table can be created no problem.

0 Likes
Message 15 of 16

kamjonggg24
Community Visitor
Community Visitor

Hi, can you help me with this too? Thank you. 456294024_485564250905761_5644114420608296138_n.jpg

0 Likes
Message 16 of 16

Sea-Haven
Mentor
Mentor

Something like what you want is best by going way back and use something like CIV3D or another Civil package "Civil site design" the labelling of field survey points and the stringing is all built in, you can control say by point type "CRB",  layer, or just pick a point and use the inbuilt labeller.

0 Likes