Jump to content

Numbering points


Isaac26a

Recommended Posts

I created this program to import points and made them include the point number as per file loaded, but how can I make to add more points but continuing the numbers that I already have. Let's say I import a file with 10 points 1-10, and then want to import another file with 50 points but those are numbered from 1-50, how can I make to the next 50 numbers become 20-60 in the drawing. How can I make a program that detects that already are points in the drawing with the numbers 1-10?. Already have them with extended data having the number.

Link to comment
Share on other sites

3 hours ago, Isaac26a said:

I created this program to import points and made them include the point number as per file loaded, but how can I make to add more points but continuing the numbers that I already have. Let's say I import a file with 10 points 1-10, and then want to import another file with 50 points but those are numbered from 1-50, how can I make to the next 50 numbers become 20-60 in the drawing. How can I make a program that detects that already are points in the drawing with the numbers 1-10?. Already have them with extended data having the number.

Attach a drawing with the first 10 points for us to evaluate. Will they always be numbered by how many there are? Are numbers ever skipped?

Link to comment
Share on other sites

1st suggestion just use lee-mac csv to list much easier to set the values of p x y etc as it will be nth 0, nth 1 etc

 

; thanks to Lee-mac for this defun 
; www.lee-mac.com
; 44 is comma
; 32 is space
(defun _csv->lst ( str / pos )
    (if (setq pos (vl-string-position 32 str))
        (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
        (list str)
    )
)

 

Very easy to do check number, find text on layer "urb_pt_num"  and check its value, if none then set pt number to 1.

 

(setq ss (ssget '((0 . "TEXT")(cons 8 "urb_pt_num"))))
(setq ptnum 0)
(if (= ss nil)
(alert "There are no points")
(progn
(repeat (setq x (sslength ss))
(setq txt (atoi (cdr (assoc 1 (entget (ssname ss (setq x (- x 1))))))))
(if (< ptnum txt)(setq ptnum txt))
)
)
)
(princ ptnum)

 

 

 

 

Link to comment
Share on other sites

ANTHER IDEA

 

(setq pipenamelist (mapcar 'cdr
	     (mapcar '(lambda(x)(assoc 1 x))
                     (mapcar 'entget(vl-remove-if 'listp
                      (mapcar 'cadr(ssnamex (ssget "X" '((0 . "TEXT") (8 . "urb_pt_num") ))))))))
              )

 

AND

 

(IF (= NIL (VL-POSITION num  pipenamelist))
          (createpoint)
       )

 

Link to comment
Share on other sites

19 minutes ago, BIGAL said:

Very easy to do check number, find text on layer "urb_pt_num"  and check its value, if none then set pt number to 1.

Thanks Bigal a good solution, but what if someone just copies only the points and not the numbers, that's why I decided to have the points with extended data. Is there a way to read the max point number from the point in the extended data?

 

Thanks Hosneyalaa, also a good way of solving the problem.

 

Link to comment
Share on other sites

For me start again and use a block with attributes. That is what most of the civil software does now. The Point symbol can be part of the block.

  • Like 1
Link to comment
Share on other sites

Listen to BIGAL!

Block with attributes is the way to go. With the attributes on separate layers you can display point numbers on or off and they would always be there. 

If you moved them around and wanted a csv file later on of the points with coordinates and numbers you could extract them easily. 

 

I've never seen points with numbers placed in a drawing as you've done.

Link to comment
Share on other sites

9 hours ago, BIGAL said:

For me start again and use a block with attributes. That is what most of the civil software does now. The Point symbol can be part of the block.

Agreed. You're making this much more difficult than it needs to be. See attached example. 

example pts.dwg

Edited by ronjonp
Link to comment
Share on other sites

Well maybe you're right and I'm not seeing the whole picture, Thanks again for your solutions and advices. I'll keep asking your later when more doubts come.

Link to comment
Share on other sites

Post a sample xyz file Ronjonp has posted the block. This an example code and has not been tested, it uses Ronjonp's "Foo" block. It will give you an idea of how much simpler it could be. I butchered code so needs cleaning up.

 

;;;;;;;;;;;; Program that import points.
;;;;;;;;;;;;
;;;;;;;;;;;; 
;;;;;;;;;;;; 20201104 V1.1 It's created
;;;;;;;;;;;;

(vl-load-com)
(defun c:import3 (/ arch descrip thenumber thedescription theelevation linea loc newlist num oldlist posdes poselev posnum
                     x y z z1)
   (setvar "cmdecho" 0)
   (vl-cmdf "_.undo" "_begin")
;;;   (oldvars)  		;;; To store the current variables
;;;   (newvars)
; thanks to Lee-mac for this defun 
; www.lee-mac.com
; 44 is comma
(defun _csv->lst ( str / pos )
    (if (setq pos (vl-string-position 44 str))
        (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
        (list str)
    )
)

   (setq arch (getfiled "Selec the file with the points ( Pt,Y,X,Z,Description )" "" "*;*" 4))   
   (setq arch (open arch "r"))
   (if (/= arch nil)
      (progn
         (vl-cmdf "_.layer" "_m" "urb_pt" "_c" "1" "" "" 
                  "_.layer" "_m" "urb_pt_num" "_c" "5" "" ""
                  "_.layer" "_m" "urb_pt_elev" "_c" "5" "" ""
                  "_.layer" "_m" "urb_pt_desc" "_c" "5" "" ""
                  "_.style" "romans" "romans" "0" "1" "" "" "" ""
         )
         (setvar "pdmode" 35)
         (setvar "pdsize" 0.3)

      )        
   )
   (while (setq linea (read-line arch))
   (setq vars  (_csv->lst  linea))
          (setq num (atoi (nth 0 vars))
          y (atof (nth 1 vars))
           x (atof (nth 2 vars))
          z (atof (nth 3  vars))
         descrip (nth 4 vars)
	)
  
          (command "-insert" "foo" (list x y z) 1 1 0 (rtos num 2 0) (rtos z 2 3) descrip)
   ) ;;; End while
   (close arch)

   (vl-cmdf  "._zoom" "E")

 
   (vl-cmdf "_.undo" "_end")
   (princ "\n")
   (princ)
)  ;;; End Importa

   
   (princ)
) ;;; End Createpoint

 

Link to comment
Share on other sites

30 minutes ago, ronjonp said:

You might look at Lee's point manager too.

Wow, you can even add attribute descriptions if you wish. 

The PDF help link he put in there is a really nice touch.

 

I thank you, Lee and others every time I use your code.

Link to comment
Share on other sites

5 hours ago, ronjonp said:

You might look at Lee's point manager too.

Yes, I have and it is very very impressive how he handles everything.

Thank you Lee for being so supportive and teaching us a better way of doing things.

 

2 hours ago, devitg said:

Devitg I don't know how it helps

Link to comment
Share on other sites

I updated the code above a bit and tested using Ronjonp foo block just copy it out of his sample dwg into a new dwg, copy, paste anywhere, erase, the definition for the block now exists in the new dwg.

 

Lee's solution is much more powerful.

 

Found a couple of minutes so contoured the points.

 

image.png.8858e660e6f5001eb950cc8d50474ff5.png

Edited by BIGAL
Link to comment
Share on other sites

On 5/24/2021 at 11:43 PM, BIGAL said:

Very easy to do check number, find text on layer "urb_pt_num"  and check its value, if none then set pt number to 1

Although using your idea, but not exactly applied to the extended data, I found the solution.

(setq ss (ssget "_X" '((0 . "POINT")(8 . "urb_pt"))))
(setq ptnum 0
      cnt1  0
)
(while (< cnt1 (sslength ss))
   (setq txt (atoi (cdr (cadadr (assoc -3 (entget (ssname ss cnt1) '("urb_pt")))))))
   (if (< ptnum txt)
       (setq ptnum txt)
   )
   (setq cnt1 (1+ cnt1))
)

 

But still interested in maybe if it's much better to do it by using a block, but still don't know how C3D users can import those points (in blocks) to use them.

And wouldn't it be better to use entmake for a block instead of insert? for multiple objects can take a while, well it's just my opinion

Link to comment
Share on other sites

Using entmake would be better just remember you got the answer for free. Your home work is change it to entmake.

 

Civ3D reads the csv file and creates COGO points, which are different to points. In CIV3D you create a style that is how the point is displayed you can have multiple styles so can do stuff like a point+elev x,y,z and so on.

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