Jump to content

Create Custom Line Table


Squirltech

Recommended Posts

In the survey business, here in Texas anyway, we do LOTS of record information ( ) and adjoiner record information [ ]. I'm trying to either create a table, in the general format shown in the image attached BUT I'd like the order of the line numbers to be L1, then (L1), then [L1] (if applicable), so on and so forth. Currently I only have the option to sort data based on ascending or descending. I've looked in all of the table options and I'm not seeing anything that will allow me to do this. Any help is appreciated.

Thanks!

T

 

Capture.JPG

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • BIGAL

    6

  • Roy_043

    6

  • Lee Mac

    5

  • Squirltech

    5

Top Posters In This Topic

Posted Images

A crude way may be to read the table into a list and hopefully Lee will read this and sort the list recognising the "(alpha" v's "alpha". Then rewrite the table in the new order. It may need a non display character so like above you have 3 characters to sort on.

Link to comment
Share on other sites

This is what I was thinking too but I have no clue how to make it happen.

 

Maybe a column on the left that is used for sorting only. A dynamic block perhaps?

Link to comment
Share on other sites

In the survey business, here in Texas anyway, we do LOTS of record information ( ) and adjoiner record information [ ]. I'm trying to either create a table, in the general format shown in the image attached BUT I'd like the order of the line numbers to be L1, then (L1), then [L1] (if applicable), so on and so forth. Currently I only have the option to sort data based on ascending or descending. I've looked in all of the table options and I'm not seeing anything that will allow me to do this. Any help is appreciated.

Thanks!

 

 

Could you possible do the in Excel. Then you can accomplish what you are trying to do.

Link to comment
Share on other sites

Weldriller try a sort on column A with (a7) 2 a3 (a6) I will save the suspense does not work thats what I tried 1st.

 

Lee where are you your the only master I know that can possibly work this out, yes may need a hidden character for (a1) v's a1

Link to comment
Share on other sites

OK Al, you got my attention :)

 

I'm not sure of the intended sort order, but the following function demonstrates a sorting method:

(defun surveysort-i ( lst )
   (vl-sort-i (mapcar 'strcase lst)
       (function
           (lambda ( a b / x y )
               (setq x (ascii a)
                     y (ascii b)
               )
               (cond
                   (   (or (= 91 x y) (= 40 x y)
                           (and (not (or (= 40 x) (= 91 x)))
                                (not (or (= 40 y) (= 91 y)))
                           )
                       )
                       (< (vl-string-trim "()[]" a) (vl-string-trim "()[]" b))
                   )
                   (   (not (or (= 40 x) (= 91 x))))
                   (   (not (or (= 40 y) (= 91 y))) nil)
                   (   (= 40 x))
               )
           )
       )
   )
)

Example:

_$ (setq lst '("L3" "[A1]" "[b1]" "(L1)" "B2" "[A2]" "(A1)" "L1" "(B1)" "A1"))

_$ (mapcar '(lambda ( n ) (nth n lst)) (surveysort-i lst))
("A1" "B2" "L1" "L3" "(A1)" "(B1)" "(L1)" "[A1]" "[A2]" "[b1]")

 

The current code will still have problems with sorting "L1" and "L10", but it demonstrates the concept.

Link to comment
Share on other sites

Thanks Lee thats a lot closer, at least now you have a sorted list and I would rewrite the whole table as I suggested in my 1st post comparing two lists the sorted as per Lee and the table entries

 

("A1" "B2" "L1" "L3" "(A1)" "(B1)" "(L1)" "[A1]" "[A2]" "[b1]")
("A1" "N23" "12" "32" "E" "401.123" "B2" "N31" "23'" "45" "E" "104.256"..........

Link to comment
Share on other sites

No need for the list comparison as the sorting function I propose uses vl-sort-i and so the indexes of the repositioned items are already known - I wanted to confirm the sort order before going any further with the example however.

Link to comment
Share on other sites

But maybe the OP wants this order?:

("A1" "(A1)" "[A1]" "[A2]" "(B1)" "[b1]" "B2" "L1" "(L1)" "L3")

 

This is what I wanted to clarify before moving any further.

Link to comment
Share on other sites

Thanks guys for your help.

 

The order I'm looking for is: A1, (A1), [A1], B2, (B2), [b2], etc

 

The table image shown in the original post gives an idea of what I'm dealing with using a LINE TABLE from Civil3d. When doing a parcel the user has the bearing & distance (B/D) of the subject line, the record B/D of the subject parcel ( ) and then the record B/D of the adjoining parcel [ ]. So when sorted, I'd like to have the first line number be without parenthesis or brackets, the next with parenthesis and the next with brackets, then that same order repeated for the next line number(s).

 

T

Link to comment
Share on other sites

The order I'm looking for is: A1, (A1), [A1], B2, (B2), [b2], etc

 

Thanks - here is a refinement of my earlier function to yield the required sort order:

(defun surveysort-i ( lst )
   (vl-sort-i (mapcar 'strcase lst)
       (function
           (lambda ( a b / x y )
               (setq x (ascii a)
                     y (ascii b)
               )
               (if (= (vl-string-trim "()[]" a) (vl-string-trim "()[]" b))
                   (cond
                       (   (not (or (= 40 x) (= 91 x))))
                       (   (not (or (= 40 y) (= 91 y))) nil)
                       (   (= 40 x))
                   )
                   (< (vl-string-trim "()[]" a) (vl-string-trim "()[]" b))
               )
           )
       )
   )
)

Alternatively, using wcmatch:

(defun surveysort-i ( lst )
   (vl-sort-i (mapcar 'strcase lst)
       (function
           (lambda ( a b / x y )
               (if (= (setq x (vl-string-trim "()[]" a)) (setq y (vl-string-trim "()[]" b)))
                   (cond
                       (   (wcmatch a "[~[(]*[~])]"))
                       (   (wcmatch b "[~[(]*[~])]") nil)
                       (   (wcmatch a "(*)"))
                   )
                   (< x y)
               )
           )
       )
   )
)

Example:

_$ (setq lst '("L3" "[A1]" "[b1]" "(L1)" "B2" "[A2]" "(A1)" "L1" "(B1)" "A1"))
("L3" "[A1]" "[b1]" "(L1)" "B2" "[A2]" "(A1)" "L1" "(B1)" "A1")
_$ (mapcar '(lambda ( n ) (nth n lst)) (surveysort-i lst))
("A1" "(A1)" "[A1]" "[A2]" "(B1)" "[b1]" "B2" "L1" "(L1)" "L3")

The table image shown in the original post gives an idea of what I'm dealing with using a LINE TABLE from Civil3d.

 

Is a 'Line Table' a type of object native to Civil 3D? Or does it appear as a standard AutoCAD table and 'Line Table' describes the table content in this context?

 

Are you able to upload a sample drawing containing a typical example of such a table?

Link to comment
Share on other sites

Or:

(defun surveysort-i (lst)
 (vl-sort-i (mapcar 'strcase lst)
   (function
     (lambda (a b)
       (< (vl-string-left-trim "([" a) (vl-string-left-trim "([" b))
     )
   )
 )
)

Link to comment
Share on other sites

Or (better):

(defun surveysort-i (lst)
 (vl-sort-i
   (mapcar '(lambda (str) (strcase (vl-string-left-trim "([" str))) lst)
   '<
 )
)

Link to comment
Share on other sites

The second is a good one, Roy.

I remember once I used something like your first code (but with vl-sort).

With vl-sort-i and the technque you demonstrate on the second code - my guess is that it should be alot faster.

Link to comment
Share on other sites

@Lee: You are right:

(setq lst '("L3" "A10" "[A10]" "[b1]" "(L1)" "(A1)" "B2" "[A2]" "(A10)" "[A1]" "L1" "(B1)" "A1"))
(mapcar '(lambda ( n ) (nth n lst)) (roy-surveysort-i lst))
=>
("A1" "(A1)" "A10" "(A10)" "[A10]" [b][color=red]"[A1]"[/color][/b] "[A2]" "(B1)" "[b1]" "B2" "L1" "(L1)" "L3")

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