Changing insertion point of an xref to that of another xref

Changing insertion point of an xref to that of another xref

Anonymous
Not applicable
1,796 Views
4 Replies
Message 1 of 5

Changing insertion point of an xref to that of another xref

Anonymous
Not applicable

Hi all,

 

I am having a problem with multiple xrefs in one layout. We have base drawing copied around drawing and X-clipped as it is used as enlaged plan of a different spaces. Thing is that I need to inser xref with other info and overlay the certain drawings. 

At the moment, I am dong it manually, attach x-ref "N", look at the insert point of the "moved" base drawing and then type to change insert point of "N".

I was looking around web but i couldnt find the right solution.

 

I founf this code posted on cad tutor link

 

with this code below, but unfortunately it doesent work... 

 

If anyone can spot the roblem or has another solution I would appreciate. 

Thanks

Jan

 

(defun C:xer  (/ 1ent 1elist 1inspnt 2ent 2elist temp)

  (acet-error-init
 (list (list "cmdecho" 0
             "osmode" (getvar "osmode")
	     "clayer" (getvar "clayer")
	     "attdia" (getvar "attdia")
          );list
       T
 );list
  );acet-error-init
  
  (layerstate-save "temp" 239 nil)

  
   
  (setq 1ent (entsel "\nSelect the source XREF with the desired insertion point:  "))
      (setq 1elist(entget (car 1ent)))
      (setq 1inspnt (cdr (assoc 10 1elist)))
  
  (setq 1nestent (nentselp (cadr 1ent)))
  (setq 1nestlist (entget (car 1nestent)))
  (setq 1nentlay (cdr (assoc 8 1nestlist)))
  (if (vl-string-search "|" 1nentlay)
    (alert "yeah!")    (alert "Object selected is not an xref. Please try again."))
    (setq 2ent (entsel "\nSelect the destination XREF to be moved:  "))
      (setq 2elist (entget 2ent))
    
      
      
      (command ".layer" "unlock" "*" "")
  	
  (setq 2elist (subst (cons 10 1inspnt)(assoc 10 2elist) 2elist))

  (entmod 2elist)

  (entupd 2ent)

  (layerstate-restore "temp")
  
  (layerstate-delete "temp")

  (command ".regenall")
  (setvar "CLAYER" CLay)
  (setvar "OSMODE" OMode)
  (setvar "CMDECHO" CEcho)
  (setvar "ATTDIA" ATTDIAmode)
  (acet-error-restore)
  (princ)
)

 

0 Likes
Accepted solutions (1)
1,797 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

Try changing

 

  (setq 2elist (entget 2ent))

 

to

 

  (setq 2elist (entget (car 2ent)))

 

as done to get the entity list from '1ent' above.  Read about what is returned by (entsel) to understand why.  Also:

 

  (entupd 2ent)

 

to

 

  (entupd (car 2ent))

 

For future reference, it's always much more helpful to describe what doesn't happen that you expect to happen, what happens that you don't expect to happen, any error messages you get, etc.  "It doesn't work" isn't much to go on.

 

There are things that could be done more simply.  For instance, there are more direct ways to determine whether a selected object is an Xref than to look at whether the Layer name of a nested object in it has a "pipe" character in it.  And there are other improvements that could be made, such as to not proceed with trying to relocate something unless the right kinds of things were selected, or better yet not to proceed even to select a second object unless the right kind of thing was selected for the first one.  But first, see whether the suggestion above at least gets it to work.

Kent Cooper, AIA
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Kent, 

Thanks for the help.

 

Unfortunately I didnt write the code as my writting skils are less than basic, I just found it on CadTutor. 

 

Suggestions you gave didnt make the routine work. Or better say something happened but xref is not moved. 

it gave me 

"AutoCAD variable setting rejected: "CLAYER" nilRegenerating model."

 

So, using those less than basic skills, i removed few lines, and it works now, but i guess i should remove those lines form the "list" in the beginning of the code...

 

(setvar "CLAYER" CLay)
  (setvar "OSMODE" OMode)
  (setvar "CMDECHO" CEcho)
  (setvar "ATTDIA" ATTDIAmode)

 

Guy who whote the code needed more than just a reposininonig of new XREF, so I guess it would be ok to remove all those layer-related functions. 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... something happened but xref is not moved. 

it gave me 

"AutoCAD variable setting rejected: "CLAYER" nilRegenerating model."

 

So ... i removed few lines, and it works now, but i guess i should remove those lines form the "list" in the beginning of the code...

 

(setvar "CLAYER" CLay)
  (setvar "OSMODE" OMode)
  (setvar "CMDECHO" CEcho)
  (setvar "ATTDIA" ATTDIAmode)

.... I guess it would be ok to remove all those layer-related functions.


That error message is definitely Layer-related, and it ought to be because the 'CLay' variable didn't have anything set in it to be set back.  But since the lines you removed [if they are the ones in your code window], which include the attempt to set that back [as well as some non-Layer-related things], come after when it should be relocating the Xref, I'm not sure what the exact problem is, unless it's in the (layerstate-save) function somehow [which comes before the relocation] -- hard to say without seeing that function definition, but if you can just get rid of all that, all should be well.

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable

OK,

Thanks Kent!

0 Likes