+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 24
  1. #1
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2014
    Location
    Amsterdam
    Posts
    30

    Default Copy text into same place but in different layer

    Registered forum members do not see this ad.

    Hi all,

    I need to translate a selction of (130) details (all different dwg files) into 6 languages.

    So what I wanted to do is copy all the text and paste them 6 times in the same location but all in 6 different layers. So for english the layername would be like Text_English, for German Text_German etc.

    How would you do this?
    Or maybe someone has a routine for it allready

    Edit:
    I already have a tool to export the text to excel and import it back into autocad after translation.

    Gr. Wesley

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,740

    Default

    Please refrain from double posting as it just causes confusion. Thank you.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  3. #3
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,175

    Default

    A quick put together no checking for layers existing etc.

    Code:
    (defun c:test ( / oldsnap ss x obj)
    (setq oldsnap (getvar "osmode"))
    (setvar "osmode" 0)
    (setq ss (ssget '((0 . "Text"))))
    (repeat (setq x (sslength ss))
      (setq obj (ssname ss (setq x (- x 1))))
        (command "copy" obj "" "0,0" "0,0") ; repeat these 2 lines as required
        (command "chprop" "L" "" "layer" "German" "") 
    )
    (setvar "osmode" oldsnap)
    (princ)
    )
    A man who never made mistakes never made anything

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,290

    Default

    EDIT: Removed previous suggestion, try this instead:
    Code:
    (defun C:test ( / *error* add c svrs LayNames s enx )
    	
    	(defun add (n i) (repeat n (setq i (1+ i))))
    	(if (not c) (setq c 0))
    	
    	(defun *error* (msg)
    		(if svrs (mapcar 'setvar (list 'cmdecho 'clipromptlines) svrs)) (princ)
    	)
    	
    	(setq LayNames ; type your languages here ("Text_" prefix will be added automatically)
    		(list
    			"English" "German" "Spanish"
    			"Russian" "Serbian" "Bulgarian"
    		)
    	)
    	
    	(setq svrs (mapcar 'getvar (list 'cmdecho 'clipromptlines)))
    	(mapcar 'setvar (list 'errno 'cmdecho 'clipromptlines) '(0 0 2))
    	
    	(mapcar
    		(function
    			(lambda (x / )
    				(or
    					(tblsearch "LAYER" x)
    					(progn
    						(entmakex
    							(list
    								(cons 0 "LAYER")
    								(cons 100 "AcDbSymbolTableRecord")
    								(cons 100 "AcDbLayerTableRecord")
    								(cons 2 x)
    								(cons 70 0)
    								(cons 62 (setq c (add 15 c)))
    							)
    						)
    						(princ (strcat "\nCreated layer: " x " !"))
    					)
    				); or
    			)
    		)	 
    		(setq LayNames (mapcar '(lambda (x) (strcat "Text_" x)) LayNames))
    	)
    	
    	(while (/= 52 (getvar 'errno))
    		(setq s (vl-catch-all-apply (function ssget) (list "_+.:E:S" (list (cons 0 "*TEXT")))))
    		(princ "\nSelect Text to Copy above the different layers")
    		(cond
    			((or (= 7 (getvar 'errno)) (null s))
    				(princ "\nYou missed, try again!")
    				(setvar 'errno 0)
    			)
    			((not (vl-catch-all-error-p s))
    				(if (setq enx (entget (ssname s 0)))
    					(progn
    						(setq s nil)
    						(foreach x LayNames 
    							(entupd 
    								(entmakex
    									(subst (cons 8 x) (assoc 8 enx) enx)
    								)
    							)
    						)
    						(princ "\nCopied the layers above the selected text !")
    					)
    				)
    			)
    			(T (setvar 'errno 52))
    		); cond
    	); while
    	(if svrs (mapcar 'setvar (list 'cmdecho 'clipromptlines) svrs))
    	
    	(princ)
    ); defun						
    Still theres a issue, since the user can't exit the selection loop by pressing ENTER .. but I'm lazy to figure it out.
    Last edited by Grrr; 21st Sep 2016 at 08:10 am.

  5. #5
    Super Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    634

    Default

    @Grrr:

    Hmm...
    Code:
    (add 11 15) => 26
    Code:
    (+ 11 15) => 26
    BricsCAD 18

  6. #6
    Super Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    634

    Default

    Quote Originally Posted by Grrr View Post
    .. but I'm lazy to figure it out.
    That is a pity.
    BricsCAD 18

  7. #7
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2014
    Location
    Amsterdam
    Posts
    30

    Default

    Thnx Grrr!
    This is a great start.

    in order to use this in a script, I would like to skip the selection of each text bij selecting all text in the drawing which is in a certain layer.
    So how do i implement the following in the script above?

    HTML Code:
    (setq s (ssget "x" '((0 . "TEXT,MTEXT")(8 . "AAc-0-TEXT"))))

  8. #8
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,290

    Default

    Quote Originally Posted by Roy_043 View Post
    @Grrr:

    Hmm...
    Code:
    (add 11 15) => 26
    Code:
    (+ 11 15) => 26
    Thanks, at first I tried to use the 1+ function, and completely forgot about the DIESEL functions.
    Btw I have everytime this "exit with enter" issue, while forcing the user to select.
    Unfortunately from where I write these codes, I can't test this behaviour (although I try any kind of checks like: vl-catch-error-p sslength (= 'pickset (type ...)).

  9. #9
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,175

    Default

    Wesley just replace the ssget line in my code above with yours ICalled the selection set ss so easiest is change you "s" to ss

    Add the two lines for the other languages required required.

    Again I have not put in the add new layer names it's quick to do anyway.

    Grr your code is a bit long winded, no disrespect, Not sure about a couple of things in it ? Clippromptlines

    Grr a little trick if you use command -la m layer1 m layer2 etc if it exists you do not get an error and lisp will continue whilst this is not really good programming it's quick and simple.
    Your correct the chprop show my age.

    I hate iPads makes my typing even worse.
    Last edited by BIGAL; 21st Sep 2016 at 12:25 pm.
    A man who never made mistakes never made anything

  10. #10
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,175

    Default

    Registered forum members do not see this ad.

    A script is just that a Lisp is also just that. A Vba is a Visual Basic program a c# is also a high level language now preferred is .Net

    Sorry but so many now call lisp coding a script.
    A man who never made mistakes never made anything

Similar Threads

  1. Separate/copy layer to other place by user pick point then sorting them..
    By nalsur8 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 16th Oct 2015, 01:11 am
  2. label line with layer name and place text
    By sroberts in forum AutoLISP, Visual LISP & DCL
    Replies: 25
    Last Post: 19th Nov 2014, 12:28 pm
  3. Copy this from one place to other
    By sham in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 26th Dec 2011, 01:41 am
  4. Place Leader line With Text(Error Layer)
    By johnpieter in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 5th Jun 2011, 03:34 am

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