vla-get-activeucs error when tilemode is 0

vla-get-activeucs error when tilemode is 0

SAPER59
Advocate Advocate
1,643 Views
10 Replies
Message 1 of 11

vla-get-activeucs error when tilemode is 0

SAPER59
Advocate
Advocate

When I use  vla-get-activeucs in model space with Tilemode set as 1 theres no problem, but if I'm in paper spacer or model when Tilemode is 0 allway crash with this message  error: Automation Error. Null object ID

What could be the reason or how to fix it

Thanks

0 Likes
1,644 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

You need to save the active UCS. Unless the UCSNAME variable is not a null string, you will get error. See below before setting a UCS name

Command: (vla-get-activeucs (vla-get-activedocument (vlax-get-acad-object)))
; error: Automation Error. Null object ID

After setting a name

 

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: named
Enter an option [Restore/Save/Delete/?]: save
Enter name to save current UCS or [?]: Trial
Command: (vla-get-activeucs (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadUCS 000000002df794b8>
It seems like in your case the modelspace has a named UCS but the paper space does not.
0 Likes
Message 3 of 11

SAPER59
Advocate
Advocate

Ranjit

Even if  (vla-getvariable Doc "UCSNAME") is /= ""   when tilemode is 0 it give the error

Even more when open the DOC in inspect window it says:   object Automation error Null object Id

And not when tilemode is 1

 

0 Likes
Message 4 of 11

Ranjit_Singh
Advisor
Advisor

That does not make any sense. Please post your drawing.

0 Likes
Message 5 of 11

SAPER59
Advocate
Advocate

Ranjit.

Thanks for your interest

It happens noy only with this DWG, 

0 Likes
Message 6 of 11

Ranjit_Singh
Advisor
Advisor

See screecast. Hopefully it clears things up. Note that (vla-getvariable (vla-get-activedocument (vlax-get-acad-object)) "ucsname") is /= "" as you said. But you need to get the variant value and test that against "". Simply use (getvar 'ucsname)

Command: (/= "" (vla-getvariable (vla-get-activedocument (vlax-get-acad-object)) "ucsname"))
T
Command: (/= "" (variant-value (vla-getvariable (vla-get-activedocument (vlax-get-acad-object)) "ucsname")))
nil

 

0 Likes
Message 7 of 11

SAPER59
Advocate
Advocate

Here I show you that it does not depend on if the UCSNAME is null or not

I'm really lost and my app fail sometimes, because sometimes works

 

0 Likes
Message 8 of 11

SAPER59
Advocate
Advocate

I upload a screncast 

http://autode.sk/2owbqf8

0 Likes
Message 9 of 11

SAPER59
Advocate
Advocate

Ranjit

I have discovered that when tilemode is set to 0 even if you are in MS mode and have an UCSNAME different from "" it gives error depending of the value of the UCSNAME when you are in PS mode . If is different from "" doesn't gives you an error but if it is "" in PS mode even if you are in MS mode and UCSNAME is not "" fails.

I will have to create something that passes frm MS to PS control the UCSNAME, and then go back. There should be some other way to know it but I think it will be a solution

Thanks in advance for your time

0 Likes
Message 10 of 11

Ranjit_Singh
Advisor
Advisor

@SAPER59 wrote:

Ranjit

I have discovered that when tilemode is set to 0 even if you are in MS mode 


Tile mode only detects model space vs all the other layouts. Irrespective of wether you are inside a viewport in a layout tab (working in model space through the viewports in paperspace) or if you are in paper space; as long as you are in a layout tab your tile mode will be 0. And at such point the active UCS is different from your model space UCS. You will get the null error until your "Active UCS" (at that instance) is named. 

Call the UCS command right before you call the vla-get-activeucs. Provide a name to the active UCS and proceed with the code. Good luck. 

EDIT: I had missed your screencast. Just checked it and I see now what you are saying. I am done with Autocad for today, but will check tomorrow again. 

0 Likes
Message 11 of 11

Ranjit_Singh
Advisor
Advisor

So I checked further and still the same results. Irrespective of whether your model space is active or paper space is active, if you are in a layout tab then your active UCS will refer to the paper space UCS. Therefore, your paper space UCS needs to be named and saved.

If you want to refer to your model space UCS, then switch to model space, (setvar 'ctab "Model") grab the activeUCS, save it to a variable and use this variable to call that object when needed.

0 Likes