Isaac26a Posted May 24, 2021 Posted May 24, 2021 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. Quote
tombu Posted May 25, 2021 Posted May 25, 2021 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? Quote
BIGAL Posted May 25, 2021 Posted May 25, 2021 Like tombu can check what is last point number but need a file and a dwg, finally post what code you have. Quote
Isaac26a Posted May 25, 2021 Author Posted May 25, 2021 Thanks to both for your interest in helping, here you have the sample and the code. It can be 1, 2 or even like thousands, and maybe like Bigal says maybe just with the last number and then continue with the numbers. 20201104 import2.lsp example pts.dwg Quote
BIGAL Posted May 25, 2021 Posted May 25, 2021 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) Quote
hosneyalaa Posted May 25, 2021 Posted May 25, 2021 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) ) Quote
Isaac26a Posted May 25, 2021 Author Posted May 25, 2021 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. Quote
BIGAL Posted May 25, 2021 Posted May 25, 2021 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. 1 Quote
tombu Posted May 25, 2021 Posted May 25, 2021 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. Quote
ronjonp Posted May 25, 2021 Posted May 25, 2021 (edited) 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 May 25, 2021 by ronjonp Quote
Isaac26a Posted May 25, 2021 Author Posted May 25, 2021 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. Quote
BIGAL Posted May 26, 2021 Posted May 26, 2021 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 Quote
Isaac26a Posted May 26, 2021 Author Posted May 26, 2021 Ok, here is a sample y,x,z file points cut n,y,x,z,des.csv Quote
tombu Posted May 26, 2021 Posted May 26, 2021 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. Quote
devitg Posted May 26, 2021 Posted May 26, 2021 it seem to be near it https://forums.autodesk.com/t5/civil-3d-forum/lisp-for-creating-circles-by-diameter-from-point-description/td-p/5495286/page/2 Quote
Isaac26a Posted May 26, 2021 Author Posted May 26, 2021 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: it seem to be near it https://forums.autodesk.com/t5/civil-3d-forum/lisp-for-creating-circles-by-diameter-from-point-description/td-p/5495286/page/2 Devitg I don't know how it helps Quote
BIGAL Posted May 26, 2021 Posted May 26, 2021 (edited) 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. Edited May 26, 2021 by BIGAL Quote
Isaac26a Posted May 26, 2021 Author Posted May 26, 2021 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 Quote
BIGAL Posted May 26, 2021 Posted May 26, 2021 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. Quote
Recommended Posts
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.