+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Using
    Land Desktop 2004
    Join Date
    Oct 2012
    Posts
    22

    Default one point relative to another for starting text

    Registered forum members do not see this ad.

    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.


    Code:
    ;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)
    			)
    		)
    	)
    )

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,746

    Default

    One of the things you can get from VL is "Vla-get-Insertionpoint txt" then just use a polar to work out next text point.
    A man who never made mistakes never made anything

  3. #3
    Junior Member
    Using
    Land Desktop 2004
    Join Date
    Oct 2012
    Posts
    22

    Default

    Wow man! Thanks! That worked great!

    Code:
    ;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)
    			)
    		)
    	)
    )

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,746

    Default

    Registered forum members do not see this ad.

    Just a suggestion it really doesn't matter your method works for osnaps
    .
    Code:
    (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)
    A man who never made mistakes never made anything

Similar Threads

  1. Arc (start-2nd-end point) absolute or relative coordinates
    By khoshravan in forum AutoCAD General
    Replies: 3
    Last Post: 5th Sep 2011, 07:22 am
  2. Leader Starting point
    By VisDak in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 17th Mar 2010, 01:55 pm
  3. Stuck in Relative point entry mode - I think..
    By J S Machine in forum AutoCAD General
    Replies: 2
    Last Post: 24th Oct 2009, 02:50 pm
  4. Define a point relative to the World UCS, not the current UCS
    By Lee Mac in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 3rd Sep 2008, 01:26 pm
  5. Starting point?
    By Rooster in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 16th Jul 2007, 03:33 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts