Jump to content

Recommended Posts

Posted (edited)

hello! it's stupid pat agian.

 

i have a new question that seems pretty difficult, since it's not just "find nearest"

 

but who knows, maybe you wizards will know the answer by heart.

 

here's what i'm trying to do, i know how to make a muitleader and all that and get the point and say it, but with these points i bring in, from a DXF, they have a name assoicated with them.

 

example 1

 

Now here's where my problem sets in, these points and thier names aren't grouped or blocked together, so they're like two diffrent entities.

ALSO i can't use find nearest because there are times where i have a bunch of points overlap.

 

example 2

 

Like above. I HAVE figured out that the text is exaclty 1 inch away from the original point and basically i'm looking for a way to search for text ONLY 1 inch apart and not 1.001 inch away. is that being WAY too specific?

 

thanks for any help.

 

[edit: sorry for the crappy resolution on the first image, i'm not an MS paint pro either.]

Edited by kapat
apology.
Posted

You may try the scenario below (in parenthesis I noted the functions to use):

  • create a selection set with all point entities from drawing (SSGET)
  • parse the above selection set and for each point create a selection set using crossing window mode and retaining only text entities; the size of the rectangle should be based on the expected distance between point and label (may be useful to increase it a little for safety) and will be centered on the current point (SSNAME, ENTGET, POLAR, SSGET)
  • the labels selection set may have more entries – calculate the distance between point and each label and retain the one that match your requirement; may be useful to validate the angle also, but only if is constant (SSNAME, ENTGET, SSGET, DISTANCE, ANGLE)

Posted

awesome, that should be enough to get me going. thanks!

  • 1 month later...
Posted (edited)

half bump, half asking for advice.

 

So i'll go ahead and give you some spoilers before you start brain compiling.

 

It's a bad SSGET, and i know that. i need to know how to fix it, what i WANT is:

from my GETPOINT i want it to find text within 1.01 inch radius from the GETPOINT.

this radius has to be all x, y, and z since i usually have to rotate all my points around, the text doesn't stay on the same z plane all the time.

 

My pointlist is probably screwy, but i'm willing to be there's an easy way of getting

 

(ssget "_WP" (ptlist circle raduis=1) (0. "TEXT"))

 

or something simple i have overlooked....

 

i also wouldn't be surprised if you guys notice i have a bad "getfiled"

since i'm pretty new to that also.

thanks for any help, or at least your time guys.

 

 


(defun c:p2f2(/ p x y z j k ptlst ptcoord textloc cs_from cs_to file text filename rstr space xlen ylen zlen modspace)

(setq fn (getfiled "save DSN as..." "c:/DESIGNDUMP/" "dsn" 1)))

(while ;start while
(setq p (getpoint "\nPick Point"))

(setq cs_from 1) ; this section keeps WCS
(setq cs_to 0)
(setq p1 (trans p cs_from cs_to 0))

(setq textloc (getpoint p "\tPLACE TEXT\n"))

(setq rstr 12) ; this section is to maintain formatting, since unformatted DSN files are sensitive.
(setq space (strcat "            "))

(setq x (rtos (car p1)))
(setq y (rtos (cadr p1)))
(setq z (rtos (caddr P1)))

(setq xlen (strlen x))
(setq ylen (strlen y))
(setq zlen (strlen z))

(setq modspacex (substr space 1 (- rstr xlen))) ; formatting length
(setq modspacey (substr space 1 (- rstr ylen)))
(setq modspacez (substr space 1 (- rstr zlen)))


(setq wiggle 1.01) ; this is where i attempt to have a SSGET using a window of wherever my point is, plus or minus 1.01 inch, since my text is exactly 1 inch away.

(setq xTEXT1 (rtos (+ (car P1) wiggle)))
(setq xTEXT2 (rtos (- (car P1) wiggle)))

(setq yTEXT1 (rtos (+ (cadr P1) wiggle)))
(setq yTEXT2 (rtos (- (cadr P1) wiggle)))

(setq zTEXT1 (rtos (+ (caddr P1) wiggle)))
(setq zTEXT2 (rtos (- (caddr P1) wiggle)))

(setq PTLST (list xtext1 xtext2 ytext1 ytext2 ztext1 ztext2)

(setq k (ssget "_WP" ptlist '((0 . "TEXT"))))

(setq ptcoord (strcat k "\t" modspacex x"\t" modspacey y"\t" modspacez z)); the string read out for the mutileader AND dsn file

(setvar "cmdecho" 0)

(command "_leader" p textloc "" ptcoord "")

(setq file (open fn))

(write-line ptcoord file)
(close file)
(princ ptcoord)

) ;end while
(setvar "cmdecho" 1)
)

 

**NOTE: the file type ".dsn" is suppose to be a text file, just with the extenstion "dsn" instead.

Edited by kapat
dsn explination, added explinations of parts of my routine.
Posted

UPDATE!

 

re-wrote my polygon window after actually understanding what i think it needed. it seems to get through the SSGET alright, but now i'm having problems with my GETFILED

 

it seems to not bring up the prompt to save as, and it doens't "set my q" or set "FN" ..... that is now my problem. i can't find enough information in getfiled other then opening files instead of "saving as"

Posted

You lost me at "while" , does that mean find the object 1 inch away at every pick point?

Posted

yeah. basically everytime i pick a point, there WILL be text exactly 1 inch away from it, it's how the DXF out command works on this other program. And during that WHILE, as i take those GETPOINTS, i want it to be writing those points into a "dsn" file.

 

here's the revised code with what SEEMS to be a good SSGET but a bad

 

error: bad variable name in SETQ: (SETQ PTCOORD (STRCAT K "\t" MODSPACEX ... ))

 

i have a strong suspision that it's my STRCAT ....

 

(defun c:p2f2(/ p x y z j k fn ptlst ptcoord textloc cs_from cs_to file text filename rstr space xlen ylen zlen modspace)

(setq fn (getfiled "save DSN as..." "c:/DESIGNDUMP/" "dsn" 1)))

(while ;start while
(setq p (getpoint "\nPick Point"))

(setq cs_from 1)
(setq cs_to 0)
(setq p1 (trans p cs_from cs_to 0))

(setq textloc (getpoint p "\tPLACE TEXT\n"))

(setq rstr 12)
(setq space (strcat "            "))

(setq x (rtos (car p1)))
(setq y (rtos (cadr p1)))
(setq z (rtos (caddr P1)))

(setq xlen (strlen x))
(setq ylen (strlen y))
(setq zlen (strlen z))

(setq modspacex (substr space 1 (- rstr xlen)))
(setq modspacey (substr space 1 (- rstr ylen)))
(setq modspacez (substr space 1 (- rstr zlen)))


(setq wiggle 1.01)

(setq xTEXT1 (rtos (+ (car P1) wiggle)))
(setq xTEXT2 (rtos (- (car P1) wiggle)))

(setq yTEXT1 (rtos (+ (cadr P1) wiggle)))
(setq yTEXT2 (rtos (- (cadr P1) wiggle)))

(setq zTEXT1 (rtos (+ (caddr P1) wiggle)))
(setq zTEXT2 (rtos (- (caddr P1) wiggle)))

(setq PTLST '((xtext1 ytext1 ztext1) (xtext1 ytext2 ztext1) (xtext1 ytext1 ztext2) (xtext1 ytext2 ztext2) (xtext2 ytext1 ztext1) (xtext2 ytext2 ztext1) (xtext2 ytext1 ztext2) (xtext2 ytext2 ztext2)))

(setq k (ssget "_WP" ptlist '((0 . "TEXT")))

(setq ptcoord (strcat k "\t" modspacex x"\t" modspacey y"\t" modspacez z))

(setvar "cmdecho" 0)

(command "_leader" p textloc "" ptcoord "")

(setq file (open fn))

(write-line ptcoord file)
(close fn)
(princ ptcoord)

) ;end while
(setvar "cmdecho" 1)
)

Posted (edited)

update agian!

 

i got pretty far, but my ssget "_WP" pointlist isn't coming out quite right. i just get stringp nil all over the place.

 

revised:

 

(defun c:p2f2 (/       p       x       y       z       j       k
       fn      ptlst   ptcoord textloc cs_from cs_to   file
       text    filename	       rstr    space   xlen    ylen
       zlen    modspace
      )


 (setq dwgname (vl-filename-base (getvar "dwgname")))
 (setq date (menucmd "M=$(edtime,$(getvar,date),MO_DD_YY)"))

 (setq	fn (getfiled "save DSN as..."
	     (strcat "c:/DESIGN_DUMP/" dwgname "-" date)
	     "dsn"
	     1
   )
 )

 (IF (/= fn nil)

   (while				;start while
     (setq p (getpoint "\nPick Point"))

      (setq cs_from 1)
      (setq cs_to 0)
      (setq p1 (trans p cs_from cs_to 0))

      (setq textloc (getpoint p "\tPLACE TEXT\n"))

      (setq rstr 12)
      (setq space (strcat "            "))

      (setq x (rtos (car P1)))
      (setq y (rtos (cadr P1)))
      (setq z (rtos (caddr P1)))

      (setq xlen (strlen x))
      (setq ylen (strlen y))
      (setq zlen (strlen z))

      (setq modspacex (substr space 1 (- rstr xlen)))
      (setq modspacey (substr space 1 (- rstr ylen)))
      (setq modspacez (substr space 1 (- rstr zlen)))


      (setq wiggle 1.01)

      (setq xTEXT1 (+ (car P) wiggle))
      (setq xTEXT2 (- (car P) wiggle))

      (setq yTEXT1 (+ (cadr P) wiggle))
      (setq yTEXT2 (- (cadr P) wiggle))

      (setq zTEXT1 (+ (caddr P) wiggle))
      (setq zTEXT2 (- (caddr P) wiggle))

      (setq point1 (xtext1 ytext1 ztext1))
      (setq point2 (xtext1 ytext2 ztext1))
      (setq point3 (xtext1 ytext1 ztext2))
      (setq point4 (xtext1 ytext2 ztext2))
      (setq point5 (xtext2 ytext1 ztext1))
      (setq point6 (xtext2 ytext2 ztext1))
      (setq point7 (xtext2 ytext1 ztext2))
      (setq point8 (xtext2 ytext2 ztext2))

      (setq ptlst (list point1	   point2    point3    point4
		 point5	   point6    point7    point8
		)
      )

      (setq k (ssget "_WP" ptlst))

      (if (= k nil)
 (setq k (rtos j 2 0))
      )

      (setq ptcoord (strcat k	      "\t"     modspacex
		     x	      "\t"     modspacey
		     y	      "\t"     modspacez
		     z	      "\t"
		    )
      )

      (setvar "cmdecho" 0)

      (command "_leader" p textloc "" ptcoord "")

      (write-line ptcoord fn)
      (close fn)
      (princ ptcoord)
      (setq j (+ j 1))
   )					;end while
 )					;end if
 (setvar "cmdecho" 1)
)

 

i'm not sure exaclty how to make a good pointlist.

if i type in "(list xtext1 ytext1 ztext1)"

THEN i get a stringp nil....

Edited by kapat
"format code in editor"

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