Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i need a lisp to detach , purge and atach the same xref file

15 REPLIES 15
Reply
Message 1 of 16
mikecharbel
1375 Views, 15 Replies

i need a lisp to detach , purge and atach the same xref file

hello , i need a lisp to detach , purge and atach the same xref file

anyone can help ?

 

thanks in advance

15 REPLIES 15
Message 2 of 16
hmsilva
in reply to: mikecharbel

Mike,

 

at this stage, I think we've all understood that you need a lisp to detach, purge and atach the same xref file...

 

Would be useful, if you provide more details...

As a demo:

(defun c:test ()
  (command "-xref" "_D" "YourXrefName"
	   "_.purge" "all" "" "_N"
	   "-xref" "_A" "YourXrefPath" "TheInsertionPoint" "Xscale" "Yscale" "RotationAngle")
)

 

Where:

"YourXrefName" -> "drawing01"
"YourXrefPath" -> "c:/path/path/drawing01.dwg"
"TheInsertionPoint" -> "0,0,0"
"Xscale" -> "1"
"Yscale" -> "1"
"RotationAngle" -> "0"

 

HTH
Henrique

EESignature

Message 3 of 16
3wood
in reply to: mikecharbel

It looks like RELOADing the xref has the same effect?

Message 4 of 16
mikecharbel
in reply to: hmsilva

thank you HMSilva

the problem is that i have a huge number of drawing and xrefs , thats why i was wondering if there any lisp routine that can copy the path and repath it after detaching and purging

hello 3wood , its not only about reloading xrefs

i need to detach and purge because i have this problem related to the visretain

where i cant get true xrefs color

and i cant change visretain because my linetypes will vary

 

Thank you all

Message 5 of 16
hmsilva
in reply to: mikecharbel

A quick one, minimally tested:

 

(defun c:test (/ ENT HND I LST LST OBJ SS)
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (repeat (setq i (sslength ss))
	(setq hnd (ssname ss (setq i (1- i)))
	      ent (entget hnd)
	      obj (vlax-ename->vla-object hnd)
	)
	(if (vlax-property-available-p obj 'Path)
	  (if (findfile (vla-get-path obj))
	    (setq
	      lst (cons	(list
			  (cdr (assoc 2 ent))
			  (vl-string-translate "\\" "/" (vla-get-path obj))
			  (cdr (assoc 10 ent))
			  (cdr (assoc 41 ent))
			  (cdr (assoc 42 ent))
			  (* 180.0 (/ (cdr (assoc 50 ent)) pi))
			)
			lst
		  )
	    )
	  );; if
	);; if
      );; repeat
      (if lst
	(progn
	  (foreach x lst
	    (command "-xref" "_D" (car x))
	  );; foreach
	  (repeat 3
	    (command "_.purge" "all" "" "_N")
	  );; repeat
	  (foreach x lst
	    (command "-xref"
		     "_A"
		     (nth 1 x)
		     (nth 2 x)
		     (nth 3 x)
		     (nth 4 x)
		     (nth 5 x)
	    )
	  );; foreach
	);; progn
      );; if
    );; progn
  );; if
  (princ)
)

 

Hope that helps

Henrique

EESignature

Message 6 of 16
mikecharbel
in reply to: hmsilva

wow , amazing , genius

Thanks a lot Henrique

but there a little problem , all xrefs in model and layout were re attached in model

is there a way to attach each one were it is ?

or to add specifying option to specify one xref , so i can do it in the model for the xref that i want to re attach

thanks a lot
 

Message 7 of 16
hmsilva
in reply to: mikecharbel

You're welcome, Mike

I have a deadline to meet today, so I don't have much free time, later on or tomorrow, I'll fix it.

Henrique

EESignature

Message 8 of 16
mikecharbel
in reply to: hmsilva

dont worry dear

thank you very much

good luck 🙂

 

Mike

Message 9 of 16
hmsilva
in reply to: mikecharbel

Mike,

here's the revised code:

 

(defun c:test (/ ENT HND I LST LST OBJ SS)
  (vl-load-com)
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (repeat (setq i (sslength ss))
	(setq hnd (ssname ss (setq i (1- i)))
	      ent (entget hnd)
	      obj (vlax-ename->vla-object hnd)
	)
	(if (vlax-property-available-p obj 'Path)
	  (if (findfile (vla-get-path obj))
	    (setq
	      lst (cons	(list
			  (cdr (assoc 2 ent))
			  (vl-string-translate "\\" "/" (vla-get-path obj))
			  (cdr (assoc 10 ent))
			  (cdr (assoc 41 ent))
			  (cdr (assoc 42 ent))
			  (* 180.0 (/ (cdr (assoc 50 ent)) pi))
			  (cdr (assoc 410 ent))
			)
			lst
		  )
	    )
	  );; if
	);; if
      );; repeat
      (if lst
	(progn
	  (setq lst (vl-sort lst (function (lambda (a b) (< (nth 6 a) (nth 6 b))))))
	  (foreach x lst
	    (command "-xref" "_D" (car x))
	  );; foreach
	  (repeat 3
	    (command "_.purge" "all" "" "_N")
	  );; repeat
	  (foreach x lst
	    (setvar 'CTAB (nth 6 x))
	    (command "-xref"
		     "_A"
		     (nth 1 x)
		     (nth 2 x)
		     (nth 3 x)
		     (nth 4 x)
		     (nth 5 x)
	    )
	  );; foreach
	);; progn
      );; if
    );; progn
  );; if
  (princ)
)

 

hope that helps
Henrique

EESignature

Message 10 of 16
mikecharbel
in reply to: hmsilva

hello Henrique ,

im sorry 😞 still have the same problem 😞

the xrefs are re attaching in the model , while i have xrefs in model , and legends , notes , title block in paper space

 

Message 11 of 16
mikecharbel
in reply to: mikecharbel

if i can select a single attach (wich i need to fix) it will be enough to me

i dont want to bother you and waste your time !!!

Message 12 of 16
mikecharbel
in reply to: hmsilva

if i can select a single attach (wich i need to fix) it will be enough to me ,

i dont want to bother you and waste your time !!!

Message 13 of 16
hmsilva
in reply to: mikecharbel


@mikecharbel wrote:

hello Henrique ,

im sorry 😞 still have the same problem 😞

the xrefs are re attaching in the model , while i have xrefs in model , and legends , notes , title block in paper space

 


Are you sure you're running the latest code?

 

Henrique

EESignature

Message 14 of 16
hmsilva
in reply to: mikecharbel

Mike,
to select a single xref, detach, purge and attach the same xref...
Today I don't have free time to rewrite the code, so
a quick and dirty...

(defun c:test (/ ENT HND LST OBJ SS)
  (vl-load-com)
  (prompt "\nSelect XREF to Detach, Purge and Attach: ")
  (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT"))))
    (progn
	(setq hnd (ssname ss 0)
	      ent (entget hnd)
	      obj (vlax-ename->vla-object hnd)
	)
	(if (vlax-property-available-p obj 'Path)
	  (if (findfile (vla-get-path obj))
	    (setq
	      lst (cons	(list
			  (cdr (assoc 2 ent))
			  (vl-string-translate "\\" "/" (vla-get-path obj))
			  (cdr (assoc 10 ent))
			  (cdr (assoc 41 ent))
			  (cdr (assoc 42 ent))
			  (* 180.0 (/ (cdr (assoc 50 ent)) pi))
			)
			lst
		  )
	    )
	  );; if
	);; if
      (if lst
	(progn
	  (foreach x lst
	    (command "-xref" "_D" (car x))
	  );; foreach
	  (repeat 3
	    (command "_.purge" "all" "" "_N")
	  );; repeat
	  (foreach x lst
	    (command "-xref"
		     "_A"
		     (nth 1 x)
		     (nth 2 x)
		     (nth 3 x)
		     (nth 4 x)
		     (nth 5 x)
	    )
	  );; foreach
	);; progn
      );; if
    );; progn
  );; if
  (princ)
)

HTH

Henrique

EESignature

Message 15 of 16
mikecharbel
in reply to: hmsilva

thank you Henrique , its more than enough for me 🙂

thans a lot

 

Message 16 of 16
hmsilva
in reply to: mikecharbel

You're welcome, Mike.
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost