Jump to content

one point relative to another for starting text


clint0577

Recommended Posts

In this lisp I'm trying to replace 4 blocks that pretty much do the same thing. I want the user to Click the point they want to use for the center of the text and the have the code calculate a certain distance, say 3.5 below on the Y axis for the next line of text.

 

 

;INSERT STREET NAME & R.O.W.
(DEFUN C:STRN ()
(SETQ CL (GETVAR "CLAYER"))
(command ".osnap" "NONE")
(setq DS (getvar 'dimscale))
(SETQ SNTW (* DS 3))
(SETQ RWTW (* DS 1.5))
(SETQ SHS (* DS 0.13))
 (setq pt1 (getpoint "\nPick insertion point for Street Name : "))
(setq sn (getstring t "\nType the Street Name: "))
(setq sr (getstring t "\nType the Right Of Way Enter VW for Variable Width or P for Public: "))
(SETQ SRW (STRCAT SR "' R.O.W."))
(COMMAND "LAYER" "S" "STREET_NAME" "")
(COMMAND "MTEXT" "_non" pt1 "J" "BC" "S" "STANDARD" "H" SHS "W" SNTW sn "")
(SETQ RHS (* DS 0.08))
(SETVAR "CECOLOR" "140")
(COMMAND "MTEXT" PAUSE "J" "BC" "S" "STANDARD" "H" RHS "W" RWTW sRW "")
(SETVAR "CECOLOR" "BYLAYER")
(COMMAND "CLAYER" CL)
(command ".osnap" "NOD,end,INT,CEN,mid")
(setq OldTxt "VW' R.O.W.")
(SETQ vwrw (STRCAT "VARIABLE WIDTH R.O.W."))

(setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))
	
(setq i (sslength ss))

(while (not (minusp (setq i (1- i))))
	(setq oText (vlax-ename->vla-object (ssname ss i)))
	(setq Txt (vlax-get-property oText 'TextString))
	
	(if (vl-string-search OldTxt txt)
		(progn
			(setq newChg (vl-string-subst VWRW OldTxt txt))
			(vlax-put-property oText 'TextString newchg)
			(vlax-invoke-method oText 'Update)
		)
	)
)
(setq P "P' R.O.W.")
(SETQ PRW (STRCAT "PUBLIC R.O.W."))

(setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))
	
(setq i (sslength ss))

(while (not (minusp (setq i (1- i))))
	(setq oText (vlax-ename->vla-object (ssname ss i)))
	(setq Txt (vlax-get-property oText 'TextString))
	
	(if (vl-string-search P txt)
		(progn
			(setq newChg (vl-string-subst PRW P txt))
			(vlax-put-property oText 'TextString newchg)
			(vlax-invoke-method oText 'Update)
		)
	)
)
)

Link to comment
Share on other sites

Wow man! Thanks! That worked great!

 

;INSERT STREET NAME & R.O.W.
(DEFUN C:STR ()
(SETQ CL (GETVAR "CLAYER"))
(command ".osnap" "NONE")
(setq DS (getvar 'dimscale))
(SETQ SNTW (* DS 3))
(SETQ RWTW (* DS 1.5))
(SETQ SHS (* DS 0.13))
(SETQ RWO (* DS 0.175))
 (setq pt1 (getpoint "\nPick Insertion Point: "))
(SETQ PT2 (polar PT1 (DTR 270.0) RWO))
(setq sn (getstring t "\nType the Street Name: "))
(setq sr (getstring t "\nType the Right Of Way Enter V for Variable Width or P for Public: "))
(SETQ SRW (STRCAT SR "' R.O.W."))
(COMMAND "LAYER" "S" "STREET_NAME" "")
(COMMAND "MTEXT" "_non" pt1 "J" "BC" "S" "STANDARD" "H" SHS "W" SNTW sn "")
(SETQ RHS (* DS 0.08))
(SETVAR "CECOLOR" "140")
(COMMAND "MTEXT" "_NON" PT2 "J" "BC" "S" "STANDARD" "H" RHS "W" RWTW sRW "")
(SETVAR "CECOLOR" "BYLAYER")
(COMMAND "CLAYER" CL)
(command ".osnap" "NOD,end,INT,CEN,mid")
(setq OldTxt "V' R.O.W.")
(SETQ vwrw (STRCAT "VARIABLE WIDTH R.O.W."))

(setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))
	
(setq i (sslength ss))

(while (not (minusp (setq i (1- i))))
	(setq oText (vlax-ename->vla-object (ssname ss i)))
	(setq Txt (vlax-get-property oText 'TextString))
	
	(if (vl-string-search OldTxt txt)
		(progn
			(setq newChg (vl-string-subst VWRW OldTxt txt))
			(vlax-put-property oText 'TextString newchg)
			(vlax-invoke-method oText 'Update)
		)
	)
)
(setq P "P' R.O.W.")
(SETQ PRW (STRCAT "PUBLIC R.O.W."))

(setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))
	
(setq i (sslength ss))

(while (not (minusp (setq i (1- i))))
	(setq oText (vlax-ename->vla-object (ssname ss i)))
	(setq Txt (vlax-get-property oText 'TextString))
	
	(if (vl-string-search P txt)
		(progn
			(setq newChg (vl-string-subst PRW P txt))
			(vlax-put-property oText 'TextString newchg)
			(vlax-invoke-method oText 'Update)
		)
	)
)
)

Link to comment
Share on other sites

Just a suggestion it really doesn't matter your method works for osnaps

.

(setvar "osmode" 0) ; no snaps
(setvar "osmode" 47)   ; (command ".osnap" "NOD,end,INT,CEN,mid")
;just set osnaps then OSMODE will give number 
;also
(setq oldsnap (getvar "osmode"))
(setvar "osmode" oldsnap)

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