ghostware Posted September 24, 2009 Share Posted September 24, 2009 Is it possible to copy and paste xdata from objects (polylines). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 24, 2009 Share Posted September 24, 2009 Do you mean copy it from one polyline to the next? Quote Link to comment Share on other sites More sharing options...
ghostware Posted September 25, 2009 Author Share Posted September 25, 2009 Yes, from polyline to the next polyline or line Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 25, 2009 Share Posted September 25, 2009 This may help you: (defun CopyAndPasteXData( RegisteredApplicationName / Entity1st Entity2nd XDataToCopy ) (setq Entity1st (car (entsel "\nSelect entity to copy from: "))) (setq XDataToCopy (assoc -3 (entget Entity1st (list RegisteredApplicationName)))) (if (not XDataToCopy) (exit)) (setq Entity2nd (car (entsel "\nSelect entity to paste on: "))) (entmod (append (entget Entity2nd) (list XDataToCopy))) ) Regards, Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 25, 2009 Share Posted September 25, 2009 Nice one Msasu An alternative approach: (defun c:CpyX (/ ss typ val dss sel) (vl-load-com) (prompt "\nSelect Source Polyline...") (while (progn (setq ss (ssget "_:S:E" '((0 . "*LINE")))) (cond ((not ss) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object (ssname ss 0))) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (if (setq dss (ssget '((0 . "*LINE")))) (progn (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-SetXdata Obj typ val)) (vla-delete sel))) (princ)) Quote Link to comment Share on other sites More sharing options...
ghostware Posted September 26, 2009 Author Share Posted September 26, 2009 Thanks!! Is it also possible to get the application name APPID (RegisteredApplicationName) from the source polyline (Entity1st) ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 26, 2009 Share Posted September 26, 2009 Ghostware, mine should copy all the xdata - irrelevant of RegApp Quote Link to comment Share on other sites More sharing options...
ghostware Posted September 26, 2009 Author Share Posted September 26, 2009 Yes CpyX.lsp works perfectly. Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 26, 2009 Share Posted September 26, 2009 No problem - to answer your original question, this will get all XData associated with an object: (defun c:getX (/ ent obj typ val) (vl-load-com) (while (progn (setq ent (car (entsel "\nSelect Object: "))) (cond ((not ent) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object ent)) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (print (apply 'mapcar (cons 'cons (list (vlax-safearray->list typ) (mapcar 'vlax-variant-value (vlax-safearray->list val)))))) (princ)) Quote Link to comment Share on other sites More sharing options...
wgatlin Posted December 2, 2009 Share Posted December 2, 2009 Lee Mac This is great. how can I modify the c:CpyX so that I can copy XDATA from any object to another object. Specifically, I am trying to copy XDATA from one AutoCAD Block to another. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 Thanks, here are the generic Functions: (defun c:getX (/ ent obj typ val) (vl-load-com) (while (progn (setq ent (car (entsel "\nSelect Object: "))) (cond ((not ent) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object ent)) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (print (apply 'mapcar (cons 'cons (list (vlax-safearray->list typ) (mapcar 'vlax-variant-value (vlax-safearray->list val)))))) (princ)) (defun c:CpyX (/ ent obj ss sel) (vl-load-com) (while (progn (setq ent (car (entsel "\nSelect Object: "))) (cond ((not ent) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object ent)) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (if (setq ss (ssget)) (progn (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-SetXdata Obj typ val)) (vla-delete sel))) (princ)) Originally posted here: http://www.theswamp.org/index.php?topic=30445.0 Quote Link to comment Share on other sites More sharing options...
wgatlin Posted December 2, 2009 Share Posted December 2, 2009 Actually I think by just playing around I got it... See any problems with this? (defun c:CyX (/ ss typ val dss sel) (vl-load-com) (prompt "\nSelect Source Block...") (while (progn (setq ss (ssget "_:S:E" '((0 . "INSERT")))) (cond ((not ss) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object (ssname ss 0))) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (prompt "\nSelect Destination Block...") (if (setq dss (ssget '((0 . "INSERT")))) (progn (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-SetXdata Obj typ val)) (vla-delete sel))) (princ)) Quote Link to comment Share on other sites More sharing options...
wgatlin Posted December 2, 2009 Share Posted December 2, 2009 Actually I think by just playing around I got it... See any problems with this? (defun c:CyX (/ ss typ val dss sel) (vl-load-com) (prompt "\nSelect Source Block...") (while (progn (setq ss (ssget "_:S:E" '((0 . "INSERT")))) (cond ((not ss) (princ "\n** Nothing Selected **")) ((progn (vla-getXData (setq Obj (vlax-ename->vla-object (ssname ss 0))) "" 'typ 'val) (or (not typ) (not val))) (princ "\n** No XData Found **"))))) (prompt "\nSelect Destination Block...") (if (setq dss (ssget '((0 . "INSERT")))) (progn (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-SetXdata Obj typ val)) (vla-delete sel))) (princ)) Quote Link to comment Share on other sites More sharing options...
wgatlin Posted December 2, 2009 Share Posted December 2, 2009 Thanks a ton for your help Lee... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 You're welcome Quote Link to comment Share on other sites More sharing options...
rooban27 Posted December 4, 2009 Share Posted December 4, 2009 Any body can help me to get the area of any object directl to excel sheet? It means, How to get the Object area directly to excel sheet? Is there any Lisp program for this? If any body has,please help me. Thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 4, 2009 Share Posted December 4, 2009 Any body can help me to get the area of any object directl to excel sheet? It means, How to get the Object area directly to excel sheet? Is there any Lisp program for this? If any body has,please help me. Thank you. This question is unrelated to the thread in which it is posted, please ask a mod to move it to a new thread, or delete it if a new thread has been made. Quote Link to comment Share on other sites More sharing options...
econnerly Posted December 19, 2014 Share Posted December 19, 2014 Bringing this thread back from the dead. Lee... I have searched around and couldn't find what I was looking for. I have a block that reads the xdata of a polyline from civil 3d. How would I be able to copy that block around and edit the xdata for each block to a given polyline? The other routine you posted copies all the data to the new block. I would just need it to copy the second line and leave all other parts of the data untouched. xdlist gives me this: * Code 1000, ASCII string: Polyline * Code 1000, ASCII string: 19CEE * Code 1000, ASCII string: * Code 1000, ASCII string: None * Code 1000, ASCII string: 0 * Code 1000, ASCII string: 2 * Code 1000, ASCII string: 2 * Code 1040, Real number: 0.00 * Code 1000, ASCII string: 0 * Code 1000, ASCII string: 2 * Code 1000, ASCII string: 0 * Code 1000, ASCII string: 2 * Code 1040, Real number: 0.00 * Code 1000, ASCII string: 0.00 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.