Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XRef Insertion to WCS regardless of current UCS

14 REPLIES 14
Reply
Message 1 of 15
liam.mulcahy
4880 Views, 14 Replies

XRef Insertion to WCS regardless of current UCS

Sometimes I'm in a rotated UCS, but of course we don't want our Xref coming in on the rotated coordinates.

 

Suggestion to either

- add a checkbox to the Attach External Reference dialog box so to insert at WCS regardless of current UCS.

- System variable where the default is to insert at WCS regardless of the current view or UCS. (I don't think I have ever wanted an xref inserted on anything other than WCS).

 

This would be a small time saver, (where I have not checked the current UCS before launching the attach xref command).

14 REPLIES 14
Message 2 of 15

Hi,

 

you might use the product feedback site >>>here<<<, it's the more direct way than posts in the forum 😉

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2024
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 3 of 15
Anonymous
in reply to: liam.mulcahy

I modified/rewrote an old lisp function for OVERLAY'ing/ATTACH'ing XREF's that sets the UCS to world prior and returns the current  UCS after.  But it requires the current version of DOSLIB to execute.

 

It will also, if you want, create a layer unique to the XREF, based on the file name (plus a prefix),  place the XREF on that layer and rename the XREF to add the prefix.

 

Remember its old and requires DOSLIB, but it works fine here.

 

Once you've installed DOSLIB you'll need to edit the attached lisp to change the path to DOSLIB at line 68 and 169 

I'm currently running AutoCAD 2015 my DOSLIB lives in directory N:\ACAD2015\CS\DOSLIB, you'll need to change that in both places it appears in the code.

 

Looks like this:

(if (not (member "doslib20x64.arx" (arx)))
(arxload "N:/ACAD2015/CS/DOSLIB/doslib20x64.arx"
"The file doslib20x64.arx was not found.")
)

(note the forward slash in the directory)

 

Once DOSLIB is installed and the list loaded, the command XTOOLS will show a list of some of the commands available in the routine.

 

Message 4 of 15
Anonymous
in reply to: Anonymous

A bit late I know but if you are an AutoCAD LT user the LISP won't work. However I use a script that does. Create a button, place it on the ribbon and you have a quick way to attach a XREF whilst keeping your current UCS. (Works on LT 2017)

 

^C^C_UCS;NA;S;TEMP;UCS;W;XATTACH;_UCS;NA;R;TEMP;_UCS;NA;D;TEMP; 

 

Let me know if you need help with buttons etc. 

 

 

Message 5 of 15
tramber
in reply to: liam.mulcahy

You can do this when you attach :

Insertion Point : *0,0

Rotation : *1,0

Beleive me, it works perfectly.

It calls the coordinates in GCS whatever is the UCS.

Message 6 of 15
Haider_of_Sweden
in reply to: tramber

I created a hotkey for the solution @Anonymous provided.

I am curious if you can turn this into a script too, ie you pick the file, and then it overrides position and rotation with the *0,0 and *1,0 values?

The benefit would be that I would never need to remember check/uncheck Specify On Screen.

Message 7 of 15
cadffm
in reply to: Haider_of_Sweden

I am not sure what you are asking for, but you can write a macro - feel free to use macros, it's your cuix. (if you are using a own custom cuix)

 

Fix insertion point, scale rotation

^C^C^C_.-XREF;;~;*0,0,0;1;1;*1,0

Asking for the Insertion point only

^C^C^C_.-XREF;;~;*\1;1;*1,0

And so on.

 

Question about -XREF command? Test it in the commandline and start the -XREF command, press F1 for reading the help

 

Sebastian

EESignature

Message 8 of 15
Haider_of_Sweden
in reply to: cadffm

Works splendid! Thanks @cadffm - it seems like I need to run this as button or hotkey, but doesn't work if drag-drop an .SCR (text-file) with the macro.

 

Can someone explain what *0,0 and *1,0 means? Can't figure out the meaning of the asterisk (*) in the context and why is it a 1 for rotation?

Message 9 of 15
cadffm
in reply to: Haider_of_Sweden

* means WCS coordinates

@ relative to the last point/ucs or current 

# absolut coordinates /ucs or current

 

Sorry, you wrote Script and my answer was for menumacro, my fail

 

in a scr

Sebastian

EESignature

Message 10 of 15
Haider_of_Sweden
in reply to: cadffm


@cadffm wrote:

* means WCS coordinates

@ relative to the last point/ucs or current 

# absolut coordinates /ucs or current


But why do I type *1,0 for rotation and not *0,0? I am not rotating, am I?

 


Sorry, you wrote Script and my answer was for menumacro, my fail

in a scr


Not at all. Rather my fault. I call everything "script". So script refers to LISP then?

But yet, macros usually work if saved in an SCR file and drag-dropped. It didn't in this case though. Not sure why.

I use SCR when I want to try out something quickly, before deciding for a place in the UI (button, hotkey etc)

Message 11 of 15
cadffm
in reply to: Haider_of_Sweden

1. My last answer was  not completed, i don't know why but it seams my copy&paste wasn't successful and i didn't notice it.

 

 

2.  Rotation input:

     The command is asking for a Rotation ANGLE. It is possible to input a number (angle) and Autocad know:

     Only a Number, ok - this is the angle my user want to rotate the xref.

     Or you answers with coordinates, then Autocad will calculate the angle for you, from ucs origin0,0,0 angle 0  to that point.

    Take a calc and give me the answer to that question: What is the angle between 0,0 and 0,0 ?

    Impossible to calculate the angle.. This is why i use 1,0 - you can use 0.533,0 or 123456,0 - it is the same result.

   Angle from 0,0 to 500,0 or 1000,0 is 0

voila.

Why i don't send just a 0 as angle direct? You are in a rotated ucs and angle0 is the angle0 of the current ucs - you don't want "this angle0"

 

3. "macros usually work if saved in an SCR file and drag-dropped."

No, thats wrong. Just for very simple and not pretty well written menu-macros is it working

 

 

Script: Ok, It's not unusual to call all these things script, also my hand written words on the paper for a program strcture is a script (also the shopping list from my wife, it she uses a good order to take the item).

But don't use this word for your autodesk - question, except you mean a script! 😉

 

Menumacro

That is what i posted before, such macros are in most of all "button" you can press in Acad,

but autocad also have SCRIPTs! Textfiles with the file extension *.SCR

If I talk about "Script" i mean autocad script, if i mean Lisp, i call it Lisp, macro = macro, action macro = action macro and VBA = VBA or VBA macro

 

For me and a lot of other users it's a good choice.

 

 

Back to the topic and SCRIPT:

In scripts you can not stop for user-input, but without:

;;START

_.-XREF
_a
D:/0.DWG
*0,0,0
1
1
*1,0

;;END

 

>"In scripts you can not stop for user-input, but without:"

oh, but if you are using LISP you can stop for User input, also in Scripts

;; MyScript

(command "_.-XREF" "_a" "D:/MyXfile.dwg" (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

 

 

Your last answer sounds that a solution by Lisp is welcome too?

Ok, the the last sample for "waitung for unser input in script" is a sample for Lisp files too.

 

(command "_.-XREF" "_a" (getfiled "" "" "dwg" 😎 (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

 

I used TRANS lisp-function for UCS->WCS, because in this case it is simpler as the "*" thing.

Sebastian

EESignature

Message 12 of 15
Haider_of_Sweden
in reply to: cadffm


@cadffm wrote:

Back to the topic and SCRIPT:

In scripts you can not stop for user-input, but without:

;;START

_.-XREF
_a
D:/0.DWG
*0,0,0
1
1
*1,0

;;END


Thanks for being a good teacher. I learned tons of new stuff, including one or two new confusions 😄

 

How come that FILEDIA does not work with XATTACH (if I wanted to use that command instead of using XREF + a known path and filename)? If I'd want to have an SCR file, I'd want the dialog to pop up and ask me what file I want to attach.

 


Your last answer sounds that a solution by Lisp is welcome too?

 

(command "_.-XREF" "_a" (getfiled "" "" "dwg" 😎 (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)


Very welcome indeed! The more options, the better, right?

It took me some time to decipher the 😎 smiley into:

(getfiled "" "" "dwg" 8)

However, I think the last part isn't correct. Didn't work for me anyway:

(trans '(1 0 0) 0 1) 1 1 0)
Message 13 of 15
cadffm
in reply to: Haider_of_Sweden

1. You never need Filedia=0 except you insert input by hand.

  Acad knows if you run a command in script maco (send)commands.

 Filedia=0 is good for testing (by hand)

 

2. Filedia is only for the standard file dialogs, but some commands have there own file dialogs.

 

3. Sorry for smileys, when i answer by a mobile it is hard to use CODE-feature.

   I answer again in few minutes from a desktop pc.

 

4. Try the -xref command by hand in the commandline and you will find the problem!?

Sebastian

EESignature

Message 14 of 15
cadffm
in reply to: cadffm


@cadffm  schrieb:

 

>"In scripts you can not stop for user-input, but without:"

oh, but if you are using LISP you can stop for User input, also in Scripts

;; MyScript

(command "_.-XREF" "_a" "D:/MyXfile.dwg" (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

 

 

Your last answer sounds that a solution by Lisp is welcome too?

Ok, the the last sample for "waiting for user input in script" is a sample for Lisp files too.

(command "_.-XREF" "_a" (getfiled "" "" "dwg"

 

(trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

 

(command "_.-XREF" "_a" (getfiled "" "" "dwg" 8) (trans (getpoint "Insertionpoint: ") 0 1) 1 1 (trans '(1 0 0) 0 1))

 

I used TRANS lisp-function for UCS->WCS, because in this case it is simpler as the "*" thing.


>"However, I think the last part isn't correct. Didn't work for me anyway:"

(command "_.-XREF" ..getfiled.... (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

Because the XREF option a(ttach) ask for

1. File / (getfiled)

2. Insertionpoint / (trans (getpoint "Insertionpount: ") 0 1) 

3. X-Scale / but i send coordinates -> (trans '(1 0 0) 0 1)

4. Y-Scale

5. Rotation

 

_.-XREF

..getfiled....

(trans (getpoint "Insertionpount: ") 0 1)

1

1

(trans '(1 0 0) 0 1)

 

all together as i edited in the quote

(command "_.-XREF" "_a" (getfiled "" "" "dwg" 8) (trans (getpoint "Insertionpoint: ") 0 1) 1 1 (trans '(1 0 0) 0 1))

 

Sebastian

EESignature

Message 15 of 15
cadffm
in reply to: cadffm

 

Please just ignore the last answer completely, I posted something wrong and noticed too late.

 

>"However, I think the last part isn't correct. Didn't work for me anyway:"

(command "_.-XREF" ..getfiled.... (trans (getpoint "Insertionpount: ") 0 1) (trans '(1 0 0) 0 1) 1 1 0)

Because the XREF option a(ttach) ask for

1. File / (getfiled)

2. Insertion point / (trans (getpoint "Insertionpount: ") 0 1)

3. X-Scale / but i send coordinates -> (trans '(1 0 0) 0 1)

4. Y-Scale

5. Rotation

 

_.-XREF

..getfiled...

..getpoint...

xscale

yscale

rotation

 

(command "_.-XREF" "_a" (getfiled "" "" "DWG" 8) (trans (setq ip (getpoint "Insertionpoint: ")) 0 1) 1 1 (trans (mapcar '+ ip '(1 0 0)) 0 1))

Sebastian

EESignature

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report