Connecting points

Connecting points

john.uhden
Mentor Mentor
5,185 Views
18 Replies
Message 1 of 19

Connecting points

john.uhden
Mentor
Mentor

BTW, I finally had a reason to write a routine to connect points with a polyline by sequential numbering.

The number is a text entity nearest each point.  Part of its value is that it will skip over any missing points numbers.  It does so by sorting the text entities in ascending numerical order and then finding the closest point to each text entity.

If anyone is interested, I will post it.

John F. Uhden

0 Likes
Accepted solutions (1)
5,186 Views
18 Replies
Replies (18)
Message 2 of 19

dbhunia
Advisor
Advisor

Check this code you wanted for......

Assuming-

-Number starting from 1 and

-Incremental order is 1, i.e. sequence is 1,2,3,4,5,6..........


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 19

john.uhden
Mentor
Mentor
Accepted solution

Thanks.  I guess that's very good if it works for you.  I was offering my own version, but you apparently don't need it.

John F. Uhden

0 Likes
Message 4 of 19

Anonymous
Not applicable

Hello.
I would like to test the version of the code that you developed

0 Likes
Message 5 of 19

Sea-Haven
Mentor
Mentor

Nice idea, from a civil point of view joining a csv file points using some form of coding or as you suggest by point number. 

 

A nice option pick 1st point pick, last point or enter numbers say version 2 

1,34

35,45

46,47

Then have multiple lines appear,

 

 

0 Likes
Message 6 of 19

john.uhden
Mentor
Mentor

I can't seem to find it.  I was working for a different company at that time.  Perhaps I left it there without taking a copy.

I'll have to look back at this thread to see if I can remember what technique I had in mind.

John F. Uhden

0 Likes
Message 7 of 19

john.uhden
Mentor
Mentor

Whatever I had had in mind, I think I recreated it...

(Also see image at bottom)

(defun c:ConnectPointsbyNumber ( / *error* var vals ss1 ss2 ent i p num nums numlocs plist pts)
   ;; Routine connects AutoCAD points in ascending order of nearest numbered text objects
   ;; (numbers must be integers from 0 to 99999)
   ;; v. 1.0 (05-06-2020) by John Uhden
   ;;  As requested by @Anonymous
   (defun *error* (error)
     (mapcar 'setvar vars vals)
     (vla-endundomark *doc*)
     (cond
       ((not error))
       ((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
       (1 (princ (strcat "\nERROR: " error)))
     )
     (princ)
   )
   (setq vars '(cmdecho osmode))
   (setq vals (mapcar 'getvar vars))
   (or *acad* (setq *acad* (vlax-get-acad-object)))
   (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
   (vla-endundomark *doc*)
   (vla-startundomark *doc*)
   (mapcar 'setvar vars '(0 0))
   (command "_.expert" (getvar "expert")) ;; dummy command
   (defun @closer (p a b)(If (< (distance p a)(distance p b)) a b))
   (and
     (setq ss1 (ssget "x" '((0 . "TEXT")(1 . "#,##,###,####,#####")(410 . "Model"))))
     (setq ss2 (ssget "X" '((0 . "POINT")(410 . "Model"))))
     (repeat (setq i (sslength ss1))
       (setq ent (entget (ssname ss1 (setq i (1- i))))
                  num (atoi (cdr (assoc 1 ent)))
                  p (cdr (assoc 10 ent))
                  nums (cons (cons num p) nums)
       )
     )
     (setq nums (vl-sort nums '(lambda (a b)(< (car a)(car b)))))
     (setq numlocs (mapcar 'cdr nums))
     (repeat (setq i (sslength ss2))
       (setq plist (cons (cdr (assoc 10 (entget (ssname ss2 (setq i (1- i)))))) plist))
     )
     (foreach p numlocs
       (setq p (car (vl-sort plist '(lambda (a b)(@closer p a b))))
                  pts (cons p pts)
                  plist (vl-remove p plist)
       )
       1
     )
     (vl-cmdf "_.pline")
     (mapcar 'vl-cmdf pts)
     (vl-cmdf "")
     (princ (strcat "\nConnected " (itoa (length pts)) " points."))
   )
   (*error* nil)
)
(defun c:CPBN ()(c:ConnectPointsByNumber))
 

John F. Uhden

0 Likes
Message 8 of 19

Sea-Haven
Mentor
Mentor

Hi John it may be possible to put this into a loop asking for pt numbers (setq ss1 (ssget "x" '((0 . "TEXT")(1 . "#,##,###,####,#####")(410 . "Model")))) by adding the -4 tests for pt number. Then will join individual group of points.

 

Need to make dummy dwg to test.

0 Likes
Message 9 of 19

Sea-Haven
Mentor
Mentor

Sorry John ignore what I said unless some one else know how to do ssget 1-9999 probably need a remove in range from selection set. After ssget "X" make a new ss so saves picking again.

 

How do you edit a post this site is very old fashioned.

0 Likes
Message 10 of 19

john.uhden
Mentor
Mentor
That could be a great improvement! Let's see what the requester says.

John F. Uhden

0 Likes
Message 11 of 19

Anonymous
Not applicable

@john.uhden Thank you very much for sharing your knowledge.
I don't have much experience with LISP.
I need to make surveying maps in Autocad.
I have points that are blocks with attributes and I would like to connect these points with polylines.
The best situation would be to be able to choose which points the polyline should use as the vertex of the polygonal, similar to Civil 3D.
I tried to use John's LISP, but it gives error: incorrect ssget character string.

 

Texto em Português:

Muito obrigado por compartilhar o seu conhecimento.
Não tenho muita experiência com LISP.
Preciso fazer mapas de agrimensura no Autocad.
Tenho pontos que são blocos com atributos e gostaria de conectar estes pontos com polilinhas.
A melhor situação seria poder escolher quais pontos a polilinha deverá utilizar como vértice da poligonal, semelhante ao Civil 3D.
Tentei utilizar a LISP do John, mas dá erro: sequência de caracteres de modo ssget incorreta.

0 Likes
Message 12 of 19

john.uhden
Mentor
Mentor
Thank you for that information.
It sounds like the points you are using are like pre-Land Desktop point
blocks, maybe like this...
Point # (attribute)
X Elev. (attribute)
Description (attribute)

Back in the day I wrote a significant piece in AutoLisp called PCONNECT
that would draw polylines (both 2D and 3D) connecting points by their
number and description, starting and stopping and creating proper curves
where applicable on specified layers.
A fellow named Rex Cooper of SmartDraft bought the code from me so I can
not even give it away. It was great for me at the time because I had lost
my job and didn't have enough money to complete a major room remodeling.
I suggest you contact Rex, perhaps send him a sample drawing, and see if
his version would work for you.

John F. Uhden

0 Likes
Message 13 of 19

Sea-Haven
Mentor
Mentor

Sounds like you solved what I call spaghetti that's what you get if you don't get the coding in correct manner.

 

I spent many years selling/supporting Civil design software and the theme is that people do not want to pay for solutions but want it for free and do everything.

 

screenshot144.png

 

 

Message 14 of 19

Sea-Haven
Mentor
Mentor

Something for you to play with

 

    1,         921.889,       4915.960,         48.250,       01F
    2,         967.024,       4921.680,         49.390,       01F   
   42,         991.021,       4920.125,         50.320,       01F 
   13,         997.129,       4919.734,         50.320,       01F 
    3,        1045.510,       4921.584,         52.090,       01F   
    4,        1126.961,       4941.480,         54.360,       01F   
    5,        1123.036,       5051.040,         56.340,       01F   
    8,        1000.876,       5079.200,         54.620,       01F   
    9,         896.378,       5054.560,         51.030,       01F   
   10,         892.944,       4978.880,         48.940,       01F   
   60,         908.003,       4946.144,         47.950,       01F*C*02F
   61,         974.643,       4980.293,         49.160,       02F
   62,         978.559,       4982.300,         49.210,       02F
   65,        1000.913,       4993.755,         49.810,       02F   
   27,        1041.413,       4959.373,         50.960,       01ETR   
   28,        1049.699,       4952.406,         51.550,       01ETR   
   29,        1063.681,       4953.335,         52.190,       01ETR   
   30,        1077.664,       4963.088,         52.610,       01ETR   
   31,        1077.146,       4976.093,         52.330,       01ETR   
   32,        1063.681,       4986.311,         51.050,       01ETR   
   51,        1040.377,       4983.060,         49.580,       01ETR   
   52,        1024.323,       4968.662,         49.610,       01ETR*C   
   33,         927.143,       5024.881,         50.760,       01BLD   
   34,         945.432,       5031.715,         51.060,       01BLD   
   35,         942.274,       5040.166,         51.050,       01BLD   
   36,         934.823,       5037.382,         51.040,       01BLD   
   37,         932.174,       5044.471,         51.040,       01BLD   
   38,         921.335,       5040.421,         50.920,       01BLD*C  
   43,         909.869,       5001.188,         49.770,       02BLD   
   44,         909.361,       4972.027,         48.770,       02BLD   
   45,         923.584,       4971.779,         48.710,       02BLD   
   46,         924.092,       5000.940,         49.740,       02BLD*C   
   80,         943.492,       4975.158,         48.670,       03BLD     
   79,         939.392,       4972.842,         48.690,       03BLD     
   81,         937.456,       4976.269,         48.710,       03BLD*R     
   92,         990.360,       4912.442,         50.160,       01ET    
   82,         999.228,       4912.467,         50.350,       02ET    
   12,         991.606,       4917.719,         50.210,       01ET    
   18,         997.221,       4917.806,         50.250,       02ET    
   14,         985.194,       4955.816,         49.030,       01ET    
   19,         992.045,       4955.560,         49.080,       02ET    
   23,         986.819,       4966.653,         48.730,       02ET    
   26,        1016.555,       4983.060,         49.440,       02ET    
   25,        1013.966,       4989.098,         49.480,       03ET    
   24,         982.625,       4975.555,         48.860,       03ET    
   20,         977.327,       4986.800,         49.480,       03ET    
   15,         969.494,       4984.416,         49.420,       01ET    
   16,         937.115,       5007.296,         49.810,       01ET    
   21,         944.947,       5011.000,         50.230,       03ET    
   17,         931.715,       5014.857,         50.140,       01ET    
   22,         942.892,       5020.324,         50.410,       03ET    
    7,        1047.843,       5074.345,         56.260,       01BB    
   59,        1049.181,       5075.023,         56.495,       01TB    
   53,        1059.538,       5054.587,         55.710,       01TB    
   54,        1073.521,       5040.189,         55.360,       01TB 
   55,        1079.735,       5025.326,         54.850,       01TB    
   56,        1095.272,       5010.928,         55.210,       01TB    
   57,        1106.665,       4991.885,         55.450,       01TB    
   58,        1123.237,       4986.311,         55.620,       01TB    
   68,        1056.431,       5053.658,         54.820,       01BB    
   69,        1072.247,       5039.348,         52.870,       01BB    
   75,        1078.182,       5022.075,         51.420,       01BB    
   76,        1093.200,       5008.141,         52.730,       01BB    
   77,        1106.289,       4989.960,         54.130,       01BB    
   78,        1123.673,       4984.363,         55.050,       01BB    
   47,         903.265,       4920.540,         47.900,       01PP    
   48,         977.438,       4934.209,         49.330,       01PP    
   49,        1052.428,       4926.214,         52.240,       01PP    
   50,        1121.126,       4957.255,         54.610,       01PP    
   11,         913.884,       4913.589,         48.120,       01EB    
  140,         934.006,       4913.235,         48.545,       01EB    
  142,         954.160,       4913.133,         48.870,       01EB    
  143,         974.044,       4912.531,         49.592,       01EB    
  144,         994.081,       4912.178,         50.250,       01EB    
   84,        1012.639,       4912.007,         50.840,       01EB*AS 
  145,        1032.575,       4912.700,         51.490,       01EB    
  146,        1052.570,       4914.981,         52.145,       01EB    
  147,        1072.391,       4919.279,         52.705,       01EB    
   85,        1081.109,       4921.539,         53.070,       01EB*AE 
  148,        1091.291,       4924.596,         53.312,       01EB    
  149,        1110.853,       4930.466,         53.644,       01EB    
   83,        1135.148,       4938.008,         54.300,       01EB    
  175,         914.086,       4910.271,         48.210,       01CL    
  176,         934.006,       4909.992,         48.635,       01CL    
  177,         954.034,       4909.832,         48.958,       01CL    
  178,         973.924,       4909.643,         49.682,       01CL    
  179,         994.028,       4909.129,         50.335,       01CL    
  180,        1012.629,       4908.802,         50.970,       01CL    
  181,        1032.822,       4909.361,         51.714,       01CL    
  182,        1053.014,       4911.763,         52.373,       01CL    
  183,        1072.843,       4915.973,         52.933,       01CL    
  184,        1081.939,       4918.546,         53.240,       01CL    
  185,        1092.183,       4921.679,         53.402,       01CL    
  186,        1111.309,       4927.528,         53.734,       01CL    
  187,        1136.040,       4935.091,         54.390,       01CL    
  188,         913.697,       4907.271,         48.130,       02EB    
  189,         933.928,       4907.340,         48.565,       02EB    
  190,         953.693,       4907.131,         48.870,       02EB    
  191,         973.760,       4906.589,         49.635,       02EB    
  192,         993.974,       4906.049,         50.370,       02EB    
  193,        1012.639,       4905.631,         51.095,       02EB*AS 
  194,        1032.730,       4906.047,         51.935,       02EB    
  195,        1053.538,       4908.453,         52.610,       02EB    
  196,        1073.617,       4912.682,         53.170,       02EB    
  197,        1082.588,       4915.183,         53.410,       02EB*AE 
  198,        1093.084,       4918.734,         53.485,       02EB    
  199,        1112.091,       4924.566,         53.675,       02EB    
  200,        1136.941,       4932.146,         54.300,       02EB    
   63,         912.980,       5050.407,         51.120,       NS      
   64,         945.606,       5055.051,         52.060,       NS
   66,         903.659,       5009.534,         49.830,       NS      
   67,         939.392,       4990.956,         49.610,       NS      
   70,         925.435,       4961.196,         48.505,       NS      
   71,         965.803,       4943.117,         48.602,       NS      
   72,        1009.823,       4926.861,         50.540,       NS      
   73,        1008.787,       4947.761,         49.710,       NS      
   74,        1011.894,       4966.340,         49.090,       NS      
   87,        1022.839,       5059.002,         54.580,       NS      
   88,        1095.853,       5037.304,         55.070,       NS      
   89,        1058.931,       5003.887,         51.130,       NS      
   90,        1042.229,       4933.608,         51.760,       NS      
   93,        1114.208,       5026.957,         55.620,       NS      
   94,        1116.830,       5009.085,         55.510,       NS      
   95,        1099.000,       5051.884,         56.210,       NS      
   96,        1074.373,       5015.350,         51.420,       NS      
   97,        1064.041,       5003.484,         51.200,       NS      
   98,        1019.144,       5067.127,         54.780,       NS      
   99,        1104.255,       5003.269,         55.340,       NS      
  100,        1095.012,       4997.584,         53.119,       NS      
  101,        1117.988,       4993.795,         55.554,       NS      
  103,        1116.932,       4980.057,         54.622,       NS      
  104,        1094.190,       5026.805,         55.060,       NS      
  105,        1081.807,       5012.743,         51.929,       NS      
  106,        1078.638,       5033.824,         55.119,       NS      
  111,        1072.035,       5027.429,         52.161,       NS      
  112,        1070.450,       5050.641,         55.676,       NS      
  113,        1058.566,       5044.719,         53.962,       NS      
  115,        1019.814,       5042.478,         53.397,       NS      
  116,        1041.839,       5034.012,         53.014,       NS      
  117,        1023.485,       5018.962,         51.680,       NS      
  118,         999.362,       5053.766,         53.497,       NS      
  119,        1002.509,       5018.492,         51.488,       NS      
  120,        1085.365,       4985.569,         52.703,       NS      
  121,        1097.951,       4964.405,         53.581,       NS      
  122,        1076.450,       4948.414,         52.711,       NS      
  123,        1030.827,       4950.295,         50.711,       NS      
  124,        1075.402,       5060.350,         56.176,       NS      
  125,        1117.354,       5042.008,         56.055,       NS      
  126,        1104.244,       4944.181,         53.976,       NS      
  127,         984.679,       5040.597,         52.390,       NS      
  128,         932.762,       5061.291,         52.170,       NS      
  129,         983.106,       5073.049,         53.888,       NS      
  130,         958.983,       5018.492,         50.803,       NS      
  131,         961.605,       5041.067,         51.744,       NS      
  132,         902.347,       4964.875,         48.590,       NS      
  133,         922.160,       4941.253,         48.065,       NS      
  134,         950.668,       4965.343,         48.638,       NS      
  135,         961.380,       4957.340,         48.530,       NS      
  136,         964.227,       4971.460,         48.726,       NS      
  137,         949.543,       4921.135,         48.610,       NS      
  138,        1024.009,       5001.560,         50.407,       NS      
  139,         896.578,       5019.903,         50.081,       NS      
    6,         976.679,       5005.819,         50.530,       TR*S4 
   39,         970.833,       5058.142,         52.590,       TR*S6  
   40,         906.313,       5029.437,         50.610,       TR*S4   
   41,         975.406,       5026.703,         51.460,       TR*S6   
  359,         946.090,       4939.956,         48.040,       TR*S8.5
0 Likes
Message 15 of 19

john.uhden
Mentor
Mentor

Might you be implying that I should not have sold the code to Rex Cooper for a profit, but should have retained ownership so I could give it away to the needy?  :]

I don't recognize those descriptors in the last response you posted, but I had set up PCONNECT for anyone to use any identification system they wanted for things like PCs and PTs, close curve, close straight, continue from, etc.

But it's no longer mine and I have no idea how it works these days; nor do I really care since my room project came out great.  I finally did something my wife likes.  And it was the most fun I've had in my life... doing all the finish work myself (alone) including ceiling moldings and built-ins.  As they say, "If you want it done right ..."

John F. Uhden

0 Likes
Message 16 of 19

Sea-Haven
Mentor
Mentor

The biggest problem is with the forums is that every one expects everything for free, you mention maybe a small fee and they will not pay. I co-authored software and from like 30 years ago but do have a agreement to improve and on sell so long as I pay a royalty. This may be an option for you and the OP.

 

Like wise developed some software gave to client to try they were blown away how good, they asked for a couple of improvements we said pay 1st that's were it ended we never got paid and they had the software I know they used it as company was bought out and new company bragged about using software when I called in one day, lawyers are to expensive to sue for costs.

 

This task can become very quickly time consuming, the question is really wether the poster is prepared pay something for an answer where commercial answers are out there already and do so much more. 

0 Likes
Message 17 of 19

john.uhden
Mentor
Mentor
Yeah, well we ARE open 24-7, and we deliver without personal contact.

John F. Uhden

0 Likes
Message 18 of 19

minhphuong_humg
Enthusiast
Enthusiast

Please, add more function to dimesion. 

Type: CPBN

To: Select 

--> dimension connect points.

Thanks.

0 Likes
Message 19 of 19

john.uhden
Mentor
Mentor

@minhphuong_humg ,

Sorry, but I have no interest in modifying something that can be obtained elsewhere.

John F. Uhden

0 Likes