Jump to content

Specify the name of the sheet from the index


ehsantavassolian

Recommended Posts

I have already written a program for regular indexing with coordinates.

 

But if the index is made of irregular rectangles :unsure:

I have an irregular index. I want to send a message based on the name of the map schema by clicking inside each rectangle

 

For example, a simple index is as follows:

 

pic 2.jpg

 

Can I click Inside a rectangle and get the message A or B or ... ?

pic 1.jpg

Link to comment
Share on other sites

Can I click Inside a rectangle and get the message A or B or ... ?

 

It's difficult to answer anything without seeing your code. What answer are you looking to be returned by clicking inside a rectangle?

Link to comment
Share on other sites

This is get text inside a pline will find A B etc.

 

; Text in polygons
; By Alan H may 2013
(vl-load-com)
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) ))
(setq coordsxy (cons xy coordsxy))
(setq I (+ I 2))
) ; end repeat
) ; end defun


; program starts here
; choose output file change acdatemp to what you want
(setq fname (strcat "c:/alan/" (getstring "\nEnter file name ")))
(setq fout (open fname "w"))
(setq plobjs (ssget (list (cons 0 "lwpolyline"))))
(setq numb1 (sslength plobjs))
(setq x numb1)
(repeat numb1
(setq obj (ssname plobjs (setq x (- x 1))))
(setq co-ords (getcoords obj))
(co-ords2xy)
; write pline co-ords here
(setq numb3 (length co-ords))
(setq z numb3)
(setq ansco-ords "")
(repeat numb3 
(setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " ))
)
(setq ans (strcat "Pline " ansco-ords))
(write-line ans fout)
(setq ansco-ords "")
(setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon
(if (= ss nil) 
(princ "\nnothing inside")
(progn 
(setq coordsxy nil) ; reset for next time
(setq numb2 (sslength ss))
(setq y numb2)
(repeat numb2
(setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
(princ anstext) ; change to write text to file
(write-line (strcat "text " anstext) fout)
(princ "\n")
) ; end repeat2
(setq ss nil) ; reset for next poly
)
)
) ; end repeat1
(close fout)
(princ)

Link to comment
Share on other sites

A simple example of what I'm asking for

 

(defun C:INDEX ()

 

(setq xy (getpoint "\n Pick Point location: "))

 

(setq x (car xy))

(setq y (cadr xy))

(setq ns nil)

 

(if (>= y 0) (if (= x 0) (if (

(if (>= y 0) (if (= x 100) (if (

(if (>= y 0) (if (= x 200) (if (

(if (>= y 100) (if (= x 0) (if (

(if (>= y 100) (if (= x 100) (if (

(if (>= y 100) (if (= x 200) (if (

 

(if (/= ns nil) (setq NameOfSheet (STRCAT "Sheet No:" ns)))

(if (/= ns nil) (alert NameOfSheet ))

(if (= ns nil) (alert "Your location is out of city"))

)

 

You can use these codes in the following cad file

0000.dwg

 

My question now is that if the small rectangles were not geometric or whole shape was rotated.

Is there a solution other than defining the coordinates?

 

pic 3.jpg

Edited by ehsantavassolian
Link to comment
Share on other sites

using ssget "fence" option you can do what you want, also need pline centroid http://www.lee-mac.com/polygoncentroid.html ps I just saved his program as "polygon centroid-lee-mac.lsp".

 

; PLACE TEXT AT CENTROID 
; BY Alan H May 2018 
; help from lee-mac polygon centroid lisp
; use (chr x) so A= 65 do x+1 then you get B and so on.

(defun c:test ( / ss ss2 pt1 pt2)
(if (not LM:PolyCentroid)(load "polygon centroid-lee-mac"))
(setq x (ascii (getstring "Enter Alpha start character say A ")))
(setq ss (ssadd ))
(While (setq pt1 (getpoint "pick 1st point"))
(setq pt2 (getpoint pt1 "Pick 2nd point"))
(setq ss2 (ssget "F" (list pt1 pt2)) )
(setq ss (acet-ss-union (list ss ss2)))
)
(alert (strcat "you have picked " (rtos (sslength ss) 2 0) " items"))
(setq Y  0)
(repeat (sslength ss)
(setq obj (ssname ss  y))
(setq pt1 (LM:PolyCentroid obj))
(command "Text" pt1 "" (chr X))
(setq x (+ x 1))
(setq y (+ y 1))
)
(princ)
)
(c:test)

 

Still having website error problems again but added Lee-Mac and A B C part

Edited by BIGAL
Link to comment
Share on other sites

  • 1 month later...

I did research and concluded that:

 

The point inside is a polygon that, if we draw a line out of it, cut the non-paired number (Odd number) of sides.

Can we write a lisp that requests us a point and then checks that:

1- A polyline whose starting point is (0,0) and the end point of that point is introduced

and

2- A polyline with default coordinates, for example ( (100,100) , (200,200) , (300,100) , and (200,0) )

3- How many times they cut each other and if their number is non-pair (Odd number) , then the point is introduced inside the figure with the default coordinates, and if it was pair (Even number) or not at all, then it is out of shape with the default coordinates.

 

please help me . . . :)

Edited by ehsantavassolian
Link to comment
Share on other sites

my $0.05 , a little trick to make unique layer for sheet frames polygon & sheetnumber TEXT only

example: layer "SHEET", then isolate layers other than this layer "SHEET". After that WP selection filter to capture TEXT (sheet number)

 

(defun c:index (/ [color="red"]p en l ss[/color] )
 ([color="blue"]layiso[/color])
(if (and (setq p (getpoint "\n Pick Point location: "))
   ([color="blue"]bpoly[/color] p)
   (setq en (entlast))
   (setq l (mapcar 'cdr (vl-remove-if-not ''((x) (= (car x) 10)) (entget en))))
   (setq en (entdel en)
	 ss (ssget [color="purple"]"WP"[/color] l '((0 . "TEXT") (8 . [color="purple"]"*"[/color])))[color="green"] ;change this to unique layer[/color]
	 )
   )
   (alert (strcat "sheet no: " (cdr (assoc 1 (entget (ssname ss 0))))))
   (alert "your location is out of city")
   )
 (vl-cmdf "_LAYERP")
 (princ)
 )

Edited by hanhphuc
variables localize
Link to comment
Share on other sites

my $0.05 , a little trick to make unique layer for sheet frames polygon & sheetnumber TEXT only

example: layer "SHEET", then isolate layers other than this layer "SHEET". After that WP selection filter to capture TEXT (sheet number)

 

(defun c:index (/ [color="red"]p en l ss[/color] )
 ([color="blue"]layiso[/color])
(if (and (setq p (getpoint "\n Pick Point location: "))
   ([color="blue"]bpoly[/color] p)
   (setq en (entlast))
   (setq l (mapcar 'cdr (vl-remove-if-not ''((x) (= (car x) 10)) (entget en))))
   (setq en (entdel en)
	 ss (ssget [color="purple"]"WP"[/color] l '((0 . "TEXT") (8 . [color="purple"]"*"[/color])))[color="green"] ;change this to unique layer[/color]
	 )
   )
   (alert (strcat "sheet no: " (cdr (assoc 1 (entget (ssname ss 0))))))
   (alert "your location is out of city")
   )
 (vl-cmdf "_LAYERP")
 (princ)
 )

 

 

 

Thank you for your efforts.

This answer is very close to my answer. :shock: :shock: :shock:

But I do not have a rectangle to choose from.

And just with the help of the four coordinates that I already have in the program I intend to do. for example ( (100,100) , (200,200) , (300,100) , and (200,0) ) :geek:

Link to comment
Share on other sites

hi, quite confusing :ouch:

 

post#1

Can I click Inside a rectangle and get the message A or B or ... ?

BIGAL post#4 & my reply post#8

 

post#2

I mean The irregular rectangles are Rotated rectangles

how about UCS ?

 

post#5

coordinates range 0 to 400 only hundreds (small scale)?

but in image shows X=14527. Y=3430863. larger scale coordinates?

0000.dwg also small scale, please provide example relevant to your problem :)

 

post#9

But I do not have a rectangle to choose from.

And just with the help of the four coordinates that I already have in the program I intend to do. for example ( (100,100) , (200,200) , (300,100) , and (200,0) )

what are these four coordinates for?

If it is a boundary, is it necessary creating new polyline ?

 

post#1

if the index is made of irregular rectangles

 

or something?

Link to comment
Share on other sites

in the coordinate system of the UTM

the indexes are perfectly vertical simple example (post#4) .

in this post I typing the command for example (index) and press enter and selecting a point on each map or empty DWG file,

then the name of the sheet is displayed for that point by alert .

 

But in the another system of coordinates, the grids are not vertical

I want to not open the index.dwg file and find my desired name of sheet.

And by typing the command for example (index) and press enter and selecting a point on each map or empty file,

the name of the sheet is displayed for that point by alert .

then I can find and open The desired DWG file.

 

please check this file.

Zone 39

index.dwg

 

one of my original files to understand what I mean

Edited by ehsantavassolian
Link to comment
Share on other sites

hi, quite confusing :ouch:

 

post#1

 

BIGAL post#4 & my reply post#8

 

post#2

 

how about UCS ?

 

post#5

coordinates range 0 to 400 only hundreds (small scale)?

but in image shows X=14527. Y=3430863. larger scale coordinates?

0000.dwg also small scale, please provide example relevant to your problem :)

 

post#9

 

what are these four coordinates for?

If it is a boundary, is it necessary creating new polyline ?

 

post#1

 

 

or something?

 

 

 

I sent you one of my original files to understand what I mean

Link to comment
Share on other sites

  • 4 weeks later...

I found the answer.

:shock::shock::shock:

 

My index.dwg

 

 

;;;;;;;;;;;;;;;;;;;; Ehsan Tavassolian 

(defun c:Index ()

(setq xy (getpoint "\n Pick Point location: "))
	(setq x (car xy))
(setq y (cadr xy))
(setq n 0 loop t)
(setq Coordinates-list '(500000 3928493 499999 3873043 454374 3873157 454653 3928608 "6160"
			545347 3928608 545626 3873157 500001 3873043 500000 3928493 "6260"
			590695 3928953 591253 3873500 545626 3873157 545347 3928608 "6360"
			364804 3984989 363955 3929528 318602 3930332 319733 3985798 "5861"
			409871 3984411 409305 3928953 363955 3929528 364804 3984989 "5961"
			454936 3984064 454653 3928608 409305 3928953 409871 3984411 "6061"
			500000 3983948 499999 3928493 454653 3928608 454936 3984064 "6161"
			545064 3984064 545347 3928608 500001 3928493 500000 3983948 "6261"
			590129 3984411 590695 3928953 545347 3928608 545064 3984064 "6361"
			635196 3984989 636045 3929528 590695 3928953 590129 3984411 "6461"
			410443 4039873 409871 3984411 364804 3984989 365663 4040454 "5962"
			455222 4039524 454936 3984064 409871 3984411 410443 4039873 "6062"
			500000 4039408 499999 3983948 454936 3984064 455222 4039524 "6162"
			544778 4039524 545064 3984064 500001 3983948 500000 4039408 "6262"
			589557 4039873 590129 3984411 545064 3984064 544778 4039524 "6362"
			634337 4040454 635196 3984989 590129 3984411 589557 4039873 "6462"))	;; list of Coordinates
 
 (while loop

(setq xa (nth 0 Coordinates-list)
      ya (nth 1 Coordinates-list)
      xb (nth 2 Coordinates-list)
      yb (nth 3 Coordinates-list)
      xc (nth 4 Coordinates-list)
      yc (nth 5 Coordinates-list)
      xd (nth 6 Coordinates-list)
      yd (nth 7 Coordinates-list)
      SheetNo (nth 8 Coordinates-list))


(setq ma (/ (- yb ya) (- xb xa)))
(if (> (- ya y) (* ma (- xa x))) (setq Quarter1 1) (setq Quarter1 0))
(setq mb (/ (- yc yb) (- xc xb)))
(if (< (- yb y) (* mb (- xb x))) (setq Quarter2 1) (setq Quarter2 0))
(setq mc (/ (- yd yc) (- xd xc)))
(if (< (- yc y) (* mc (- xc x))) (setq Quarter3 1) (setq Quarter3 0))
(setq md (/ (- ya yd) (- xa xd)))
(if (> (- yd y) (* md (- xd x))) (setq Quarter4 1) (setq Quarter4 0))

(if (and (OR (AND (= Quarter1 1) (= Quarter3 1)) (AND (= Quarter1 0) (= Quarter3 0))) (OR (AND (= Quarter2 1) (= Quarter4 1)) (AND (= Quarter2 0) (= Quarter4 0))))
  
	(progn
		(setq loop nil)
		;(alert (strcat "OK " SheetNo))
	  	(et:iii25000)


	  
	);; End progn
  
  	(progn	;; Else
		(setq n (+ n 1))

	  	(if (> n 16)		;; tedade sheet ha - number of sheets
			(progn
				(setq loop nil)
			  	(alert (strcat "your location is out of city"))
			)
			(progn
			  	(setq Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list)))
				      Coordinates-list (append (cdr Coordinates-list)(list (car Coordinates-list))) )
			  	(princ)
			)
	  	)
	);; End Else
  
);; End if

 );; End while

);; End m25


(defun et:iii25000 ()



(setq xe (abs (+ xa (/ (- xb xa) 2)))
      ye (abs (+ ya (/ (- yb ya) 2)))
      xf (abs (+ xb (/ (- xc xb) 2)))
      yf (abs (+ yb (/ (- yc yb) 2)))
      xg (abs (+ xc (/ (- xd xc) 2)))
      yg (abs (+ yc (/ (- yd yc) 2)))
      xh (abs (+ xd (/ (- xa xd) 2)))
      yh (abs (+ yd (/ (- ya yd) 2)))
      xi (abs (+ xh (/ (- xf xh) 2)))
      yi (abs (+ yh (/ (- yf yh) 2))) )

(setq me (/ (- ye yg) (- xe xg)))
(if (or (and (> (- ye y) (* me (- xe x))) (> xf xh)) (and (> (- ye y) (* me (- xe x))) (< xf xh))) (setq Quarter11 1) (setq Quarter11 0))
(setq mf (/ (- yf yh) (- xf xh)))
(if (or (and (< (- yf y) (* mf (- xf x))) (> ye yg)) (and (> (- yf y) (* mf (- xf x))) (< ye yg))) (setq Quarter12 1) (setq Quarter12 0))


(if (and (= Quarter11 0) (= Quarter12 1) )
	(progn
	  	(setq SheetNo (strcat SheetNo " 1"))
		(setq xa xa ya ya xb xe yb ye xc xi yc yi xd xh yd yh)
	  	;(alert (strcat SheetNo))
	  	(et:iiii25000)
	)
)
(if (and (= Quarter11 1) (= Quarter12 1) )
	(progn
	  	(setq SheetNo (strcat SheetNo " 2"))
		(setq xa xe ya ye xb xb yb yb xc xf yc yf xd xi yd yi)
	  	;(alert (strcat SheetNo))
	  	(et:iiii25000)
	)
)
(if (and (= Quarter11 1) (= Quarter12 0) )
	(progn
	  	(setq SheetNo (strcat SheetNo " 3"))
		(setq xa xi ya yi xb xf yb yf xc xc yc yc xd xg yd yg)
	  	;(alert (strcat SheetNo))
	  	(et:iiii25000)
	)
)
(if (and (= Quarter11 0) (= Quarter12 0) )
	(progn
	  	(setq SheetNo (strcat SheetNo " 4"))
		(setq xa xh ya yh xb xi yb yi xc xg yc yg xd xd yd yd)
	  	;(alert (strcat SheetNo))
	  	(et:iiii25000)
	)
)

);; End iii25000


(defun et:iiii25000 ()


(setq xe (abs (+ xa (/ (- xb xa) 2)))
      ye (abs (+ ya (/ (- yb ya) 2)))
      xf (abs (+ xb (/ (- xc xb) 2)))
      yf (abs (+ yb (/ (- yc yb) 2)))
      xg (abs (+ xc (/ (- xd xc) 2)))
      yg (abs (+ yc (/ (- yd yc) 2)))
      xh (abs (+ xd (/ (- xa xd) 2)))
      yh (abs (+ yd (/ (- ya yd) 2))) )

(setq me (/ (- ye yg) (- xe xg)))
(if (or (and (> (- ye y) (* me (- xe x))) (> xf xh)) (and (> (- ye y) (* me (- xe x))) (< xf xh))) (setq Quarter111 1) (setq Quarter111 0))
(setq mf (/ (- yf yh) (- xf xh)))
(if (or (and (< (- yf y) (* mf (- xf x))) (> ye yg)) (and (> (- yf y) (* mf (- xf x))) (< ye yg))) (setq Quarter112 1) (setq Quarter112 0))


(if (and (= Quarter111 0) (= Quarter112 1))
	(progn
	  	(alert (strcat SheetNo " ne"))

	)
)
(if (and (= Quarter111 1) (= Quarter112 1))
	(progn
	  	(alert (strcat SheetNo " se"))
	)
)
(if (and (= Quarter111 1) (= Quarter112 0))
	(progn
	  	(alert (strcat SheetNo " sw"))
	)
)
(if (and (= Quarter111 0) (= Quarter112 0))
	(progn
	  	(alert (strcat SheetNo " nw"))
	)
)

);; End iiii25000

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