Jump to content

Generate Lot/Polygon Data to table Help. Mr. Lee, pBe, BIGAL. Need help once more.


makimaki

Recommended Posts

I have an attached dwg here. I want a list routine that will extract the lot's (from mother lot to sublots) bearings and distances just like in the dwg. The tables will be inserted one by one like mother lot first, then sublot-a then sublot-b and so on. (also the bearings and distances from the reference point to the different corner 1) Thank you so much. I really need this routine to finish my study. I've read tutorials and blogs, but still can't get it right. Hope that someone can help me. thanks. :)

Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • makimaki

    16

  • pBe

    15

  • ymg3

    1

  • ian egina

    1

Top Posters In This Topic

..I really need this routine to finish my study. I've read tutorials and blogs, but still can't get it right.

 

Show us what you have now, and we will guide you, but you have to write the code on your own. How s that sound?

Link to comment
Share on other sites

makimaki,

 

Here's one I did a while ago. You will need to adjust

the constant value at beginning of program.

 

Also need to modify for bearing use.

 

Probably you can use a lot of the stuff in there

and then customize to your taste.

dt.LSP

Link to comment
Share on other sites

As a starting point for you makimaki

 

(if
     (and (select Text)				; "Ldx_Data"			entsel / ssget with filter
          (Pick Start point))				; To determine Point nos 1 	getpoint
     	(progn
     	(while  (Pick Next point [ Start point ])	;				getpoijnt
             (distance SP NP)				; Value for distance		distance
             (angle SP NP)				; Value for Bearing		angle
             (convert distance to string)		; For table 			rtos / strcat
             (convert angle to string)			; For table 			angtos
      (replace "d" with "%%d")			; vl-string-subst
             (pass the values to a list)		; cons / list
             )
          (Pick Insertion point for table)		;				getpoint 
(Insert Attribute Block for Lot Title)			; Native insert command / Attreq
       [Values: from (select Text) ]			; cdr / assoc / entget
(Insert Attribute Block for LINE/BEARING/DISTANCE)	; Native insert command / Attreq / polar
       [Values: from (convert distance to string) 	; variable
	      (convert angle to string) ]	; variable
       )
     )
     

 

Start writing the code :)

 

Data.dwg

LotTitle.dwg

MainTitle.dwg

Edited by pBe
Link to comment
Share on other sites

@makimaki

 

How did it go with the coding? Any progress? Or are you wanting a more "automagically" routine? MY goal here is to guide and teach you the basics of writing a code. We can give you a more complex PSEUDO CODE [or a working routine ] but the point here is, we want you to learn like everybody else [ well not really, there are still users here that posts I WANT.... / I NEED... even after a hundred or posts under their name ].. Hope you are not one them :)

 

Dont be bashful, go ahead and asks away......

 

Cheers

pBe

Link to comment
Share on other sites

@ymg Thank you for the code you posted.

 

@pBe. don't worry master, I totally got your point and Im grateful of your suggestion. Im quite busy right now because Im writing a manuscript about my thesis though I started making the code but it is still not finished. I'll post it ASAP. Thank you again master pBe. :D

Link to comment
Share on other sites

Thats he spirit makimaki :thumbsup:

 

Go for it, and show us what you got. Holler if you need help

 

Good luck dude :)

 

I have now the code master pBe. It really took time. :P

(vl-load-com)
(defun C:TD (/ *error* acsp ang atable cnt col dist item osm
     point_list pt row table_data tmp tmp_data)

  (defun *error*  (msg)
    (if (and msg
      (not
        (member msg
         '("console break" "Function cancelled" "quit / exit abort"))))
      (princ (strcat "\nError: " msg))
      )
    (if osm
      (setvar "osmode" osm))
    (princ)
    )
 (command "layer" "m" "Technical Description" "") 
 (command "layer" "c" "7" "Technical Description" "") 
 (command "color" "bylayer")
 (initget 1) 

(setq osm (getvar "osmode"))
(setvar "osmode" 1)

(setq cnt 1)
(while (setq pt (getpoint
    (strcat "\n  Specify Corner #"
     (itoa cnt)
     " (hit Enter after the last corner) >> ")))
  (setq point_list (cons pt point_list)
 cnt    (1+ cnt))
  )
(setq point_list (reverse point_list))

(setq cnt 0)
(while (<= cnt (- (length point_list) 2))
  (setq tmp  (list (strcat (itoa (1+ cnt)) " - " (itoa (+ cnt 2)))
         (nth cnt point_list)
         (nth (1+ cnt) point_list))
 tmp_data (cons tmp tmp_data)
 )
  (setq cnt (1+ cnt))
  )
(setq tmp      (list (strcat (itoa (length point_list)) " - 1")
       (last point_list)
       (car point_list))
      tmp_data (cons tmp tmp_data)
      )
(setq tmp_data (reverse tmp_data))
(foreach item  tmp_data
  (setq ang (angle (cadr item) (caddr item)))
  (setq ang (angtos ang 4 2))
  (setq dist (distance (cadr item) (caddr item)))
  (setq dist (strcat (rtos dist 2 2) " m."))
  (setq tmp (list (car item) ang dist))
  (setq table_data (cons tmp table_data))
  )
(setq table_data (reverse table_data))
(setq pt (getpoint "\n  Specify insertion point of Technical Descriptions"))
(setq acsp (vla-get-block
      (vla-get-activelayout
        (vla-get-activedocument
   (vlax-get-acad-object))))
      )
(setq atable
       (vlax-invoke
  acsp
  'AddTable
  pt
  (+ 2 (length table_data))
  (length (car table_data))
  (* (getvar "textsize") 2.0)
  (* (getvar "textsize") 15))
      )
(vla-put-regeneratetablesuppressed atable :vlax-true)
(vla-settextheight atable actitlerow (getvar "textsize"))
(vla-settextheight atable acheaderrow (getvar "textsize"))
(vla-settextheight atable acdatarow (getvar "textsize"))
(vla-put-vertcellmargin atable (/ (getvar "textsize") 4.25))
(vla-settext atable 0 0 "TECHNICAL DESCRIPTIONS")
(vla-settext atable 1 0 "LINES")
(vla-settext atable 1 1 "BEARINGS")
(vla-settext atable 1 2 "DISTANCES")
(setq row 2)
(foreach item  table_data
  (setq col 0)
  (foreach x  item
    (vla-settext atable row col x)
    (vla-setcellalignment atable row col acMiddleCenter)
    (setq col (1+ col)))
  (setq row (1+ row))
  )

  (vla-put-regeneratetablesuppressed atable :vlax-false)

  (*error* nil)

  (princ)
)

 

Problems encountered that I don't know how to solve.

 

1. For the Boundary: I can't generate the format of the table as seen in the file help.dwg. In this lisp, I can only make a table that shows "Technical Description Column", then "Lines Bearings Distances column" and then the "DATA Column". This is because this lisp follows the default format in tabulating data into a table. I want the table to be generated to be like in the help.dwg file. Column 1 = Techincal Descriptions; Column 2 = LINE BEARING DISTANCE; then column 3 the word "BOUNDARY", then column 4 and beyond, the DATA.

 

2. For the sublots: Same problem as with the boundary. I can't format the table the same as in the help.dwg

 

3. I don't know how to change the degree sign from "d" to "o".

 

I really need your help master pBe. my time is running out :(

 

PS. Yes you are right, I'm learning a lot because of your suggestion and Im very grateful for it. Thank you so much master pBe.

 

regards

makimaki

Link to comment
Share on other sites

I have now the code master pBe. It really took time. :P

 

Good for you Makimaki, you wrote this code by yourself? I have to say i'm impressed. :)

I was thinking you would start from vanilla and use block insertion instead you use ACAD_TABLE.

 

 

1. For the Boundary: I can't generate the format of the table as seen in the file help.dwg. In this lisp, I can only make a table that shows "Technical Description Column", then "Lines Bearings Distances column" and then the "DATA Column". This is because this lisp follows the default format in tabulating data into a table. I want the table to be generated to be like in the help.dwg file. Column 1 = Techincal Descriptions; Column 2 = LINE BEARING DISTANCE; then column 3 the word "BOUNDARY", then column 4 and beyond, the DATA.

 

I guess you meant "ROW"

 

I do not see in your code where you prompt or retrieve via selection the name of the LOT, you may need to add that.

 

 
[color="silver"](vla-settext atable 1 2 "DISTANCES")[/color]
[b](vla-InsertRowsAndInherit atable 2 0 1)[/b]
[b] (vla-settext atable 2 0 "WHERE YOU GET THE TITLE") [/b]    
[color="silver"](setq row [/color][b]3[/b])
 [color="silver"]   (foreach item  table_data[/color]

 

3. I don't know how to change the degree sign from "d" to "o".

 

Look into (vl-string-subst "new" "old" str)

I also notice on your "help.dwg", you are using a leading "0" for single digit i.e "05" number. Are you planning to incorporate that? and how?

 

PS. Yes you are right, I'm learning a lot because of your suggestion and Im very grateful for it. Thank you so much master pBe.

 

Funny you said that, as i dont see any resemblance to the pseudo code i posted :lol:

I'm happy to help :)

Link to comment
Share on other sites

Hello Master pBe. I've been really busy lately, sorry for the late reply. :)

Honestly, the code I've posted was not originally all from me. Ive researched tutorials and forums related to my topic, combined them and specify it into my own. :)

 

1. Problem 1 has been solved master pBe. Thank you so much.

2. For Problem 2, I don't know how to generate a table just like in help.dwg for sublots. It should look like this:

l SUBLOT NAME l ==============> ROW 1/ Header

l 1-2 l Data for Bearings l Data for Distance l ==============> ROW 2/ Data Table

l 2-3 l Data for Bearings l Data for Distance l ==============> DATA/ table

and so on . . . . . . . .

 

Note: As you can observe in the code ive posted. The "while" function is at the start of the routine, I am planning to transfer it after the table of the mother lot or the "boundary table" has been generate so that the codes for generating the table for the sublots should go again and again until all sublots has been tabulated. I already know how to do this master pBe, my problem now is that I don't know how to format my table just like in help.dwg.

 

3. I still don't know how to change the degree sign. Can you show me the solution master just like what you did in solving problem 1 before? Thank you so much again master pBe. :)

 

More power!

 

regards,

makimaki

Link to comment
Share on other sites

Ok makimaki, enough of the "master" thingy :lol:

 

2. That is why i suggested using blocks instead of ACAD_TABLE. it is loads easier to code for a newbie Tell me, do you still want to continue with ACAD_TABLE? My next suggestion will depend on your answer. [item #2]

 

3. vl-string-subst

(setq ang (vl-string-subst "%%d" "d" (angtos ang 4 2)))

 

But then again, do you need the leading "0" for single digit value "S 075d29' W"

Link to comment
Share on other sites

hello pBe. :)

 

for #2. Maybe I'll take your suggestion about using blocks. Please do help me because using blocks, I have totally zero knowledge :( Thanks pBe.

 

for #3. funny, I was experimenting last night and fortunately I got it right. We have the same code. hahaha.

Yes, I need the leading "0" for single digits. (i.e. : S 7d29' W would turn to S 07d29' W ; S 23d9' W would turn to S 23d09' W. I don't know how to do that. Thanks in advance pBe for the help. :)

 

regards

makimaki

Link to comment
Share on other sites

Wait a minute makimaki, you're tricking me into writing the code for you :lol:

 

What about the TITLE [what will be the source for that? prompt and/or select?

Link to comment
Share on other sites

Wait a minute makimaki, you're tricking me into writing the code for you :lol:

 

What about the TITLE [what will be the source for that? prompt and/or select?

 

Hahaha. you got me. But I really need your help. I don't have enough time, the defend of my study will be in 3 days. :(

 

Selecting a text would be better for the source of the title. Remember the code you helped me for Lot and Sublot Numbering? The user would select the Lot or Sublot number to serve as the source of the title.

Thank you so much again pBe. Don't worry, I'll include you in my acknowledgement and even show/upload you my study so that you will know how much you helped me. :) THanks again sir pBe. :)

Link to comment
Share on other sites

We will use Vanilla code and blocks

 

(defun c:maki2 ( / _pad0angtos data sn title sp np bearing dst data Main_start data_ip
                	LineValue1 LineValue2 BearingValue DistanceValue)
;;;	   	  	 Vanilla code			;;;
;;; 			pBe 31 Marc 2015		;;;

(defun _pad0angtos  (br / i n)
(setq i 2
    l (strlen br))
(while (/= (substr br (setq i (1+ i)) 1) "d"))
(setq n    (mapcar '(lambda (n)
                        (strcat (if (< (setq n (atoi n)) 10)
                                    "0"  "")
                              (itoa n)))
                 (list (substr br 2) (substr br (setq i (1+ i))))))
(strcat (substr br 1 2)
      (car n)  "%%d" (cadr n)
      (substr br (- l 2)))
)
     (setq main_start nil)
     (setvar 'Attdia 0)
     (setvar 'Attreq 1)
     (command "-layer" "m" "Technical Description" "") 
     (command "-layer" "c" "7" "Technical Description" "") 
     (setvar "cecolor" "bylayer")
     
     
     	(while
             (and (progn
                        (setq data nil SN 1)
                        (initget "N")
                        (setq Title (entsel "\nSelect Lot Name Text / N for name: "))
                        (and Title
                         (setq Title (if (eq Title "N")
                             	(strcase (getstring "\Enter Lot Name : "))
                                	(if (member (cdr (assoc 0 (setq ent (entget (car Title))))) '("TEXT" "MTEXT"))
                                            	(cdr (assoc 1 ent)))))
                             (snvalid Title))
                        )
                  (setq sp (getpoint "\nPick Start Point"))
                  (setq sp_ sp)
                  )
	(while
              (setq np (getpoint sp "\nPick Next Point"))
              (setq dst (distance sp np))
	      (setq bearing (angle sp np))				
	      (setq dst (Strcat (rtos dst 2 2) " m."))	
	      (setq bearing (angtos bearing 4 2))
              (setq bearing (_pad0angtos bearing))
	      (setq data (cons
                               (list (itoa sn)  Bearing dst np) data))
              (setq sp np sn (+ 1 sn))
              )
             (setq data (cons (list  (itoa sn)
              		      (_pad0angtos (angtos (angle sp sp_) 4 2))
                                     (Strcat (rtos (distance sp sp_) 2 2) " m.")) data))
             (setq data (reverse (cons (last data) data)))

          (if (null Main_start)
                 (progn
             		(setq Main_start (getpoint "\nPick Insertion point for Main Title location"))
             		(command "-Insert" "MainTitle" "_non" Main_start "" "")
                       
                       (setq Data_ip (polar Main_start (* pi 1.5) 6.0))
                       )
                 )
        (command "-Insert" "LotTitle" "_non" Data_ip "" "" Title )
        (while (and (setq data1 (car data))
                   (setq data2 (cadr data)))
             (setq Data_ip (polar Data_ip (* pi 1.5) 1.6))
             (setq LineValue1 (car data1))
             (setq LineValue2 (car data2))
             (setq BearingValue (cadr data1))
             (setq DistanceValue (caddr data1))
             (command "-Insert" "Data" "_non" Data_ip "" ""
                  LineValue1
                  LineValue2
                  BearingValue
                  DistanceValue
                   )
             	   
             	   (Setq data (cdr data)))
                 
       (command "-Insert" "table_close" "_non" Data_ip "" ""  )
       (setq Data_ip (polar Data_ip (* pi 1.5) 3.0))     
       )
     
     (princ)
)

 

BLLM: For Tie Lines

 

(defun c:bllm ( / BLLM# BLLM_N BLLM_E BLLMDATA BLLMC Title BLLMipt BLLMipt)
     (if (and
	(setq BLLM# (getint "\nEnter BLLM Nos.: "))
	(setq BLLM_N (getreal "\nEnter Northing: "))
	(setq BLLM_E (getreal "\nEnter Easting: "))
               )
     (progn
       (setq BLLMDATA nil
             BLLMC    (list BLLM_E BLLM_N))
(while
             (and (setq Title (strcase (getstring "\nEnter Lot Name: ")))
	   (snvalid Title)
                  (setq sp (getpoint BLLMC (Strcat "\nPick corner # 1 for " Title )))
                  )
             (setq BLLMDATA (cons (list title (_pad0angtos (angtos (angle  BLLMC sp)))
                                         (strcat (rtos (distance BLLMC sp) 2 2) " m.")) BLLMDATA))
             )
       (setq BLLMipt (getpoint  "\nPick BLLM table insertion point"))
       (command "-Insert" "BLLM_Title" "_non" BLLMipt "" "" (itoa BLLM# ))
       (setq BLLMData_ip (polar BLLMipt (* pi 1.5) 7.6))
       (foreach TieLines (reverse BLLMDATA)
             (command "-Insert" "BLLM_Data" "_non" BLLMData_ip "" ""
                  (car TieLines)
                   (cadr TieLines)
                   (last TieLines)
                   )
           (setq BLLMData_ipp BLLMData_ip
                 BLLMData_ip (polar BLLMData_ip (* pi 1.5) 1.6))  
             )
             	(command "-Insert" "table_close" "_non" BLLMData_ipp "" ""  )
       )
         )
     (princ)
     )

 

BLLM Blocks

BLLM_Title.dwg

BLLM_Data.dwg

 

Maki2 Blocks

LotTitle.dwg

Data.dwg

MainTitle.dwg

 

Common Blocks for BLLM and Maki2

table_close.dwg

 

Command: Select Lot Name Text / N for name:

 

This prompt will ask the user to select a TEXT/MTEXT or if there are no object entity to select the user can type "N" to prompt for name

 

HTH

Edited by pBe
Link to comment
Share on other sites

We will use Vanilla code and blocks

 

Command: Select Lot Name Text / N for name:

 

This prompt will ask the user to select a TEXT/MTEXT or if there are no object entity to select the user can type "N" to prompt for name

 

HTH

 

Thank you very much sir pBe. Just finished converting your dwg files to 2010 via true view because I only have aCAD2010.

 

1. I'm a little bit confused by your routine sir. First, it will ask me so select or prompt a name for the lot name, after that it will ask me to select points of the boundary, after I clicked enter, a block attrib dialogue box will appear and ask for the name. I don't how it works. Or this is happening because I have 2010 aCAD.

 

2. Is this routine independent or should I combine it with the first code? Thanks for the help sir pBe. :)

Link to comment
Share on other sites

oops. :lol:

 

Figure out what makes the dialog box appear when insert command prompts for attribute values Makimaki. and include that on the code

 

as for this line from the original code

(command "cecolor" "bylayer") change it to (setvar "cecolor" "bylayer") [

Link to comment
Share on other sites

poor thing me. I really don't know what to do sir pBe. :(

 

Seriously Makimaki?

 

ATTREQ 1

ATTDIA 0

 

Anyhoo. Refer to UPDATED CODE at post # 16

 

EDIT: hang on, I saw a bug there, the last point to point 1 [ silly me ]...UPDATED

Edited by pBe
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...