Jump to content

Recommended Posts

Posted

Hi,

 

I am running a third party program that publishes a drawing by zooming to extents and then creating a DWF of the display. This causes random scaling and placement issues. To fix this I am running a routine that adjusts the screensize to fix the aspect ratio before the publish is run.

 

Here is the problem, The screensize system variable will not update until you have completely exited AutoLISP and are back at the command line.

 

Question 1. Is there a way to force an update to the screensize sysvar after setting the window

 

Question 2. Can I change the screensize before I open the drawing? I've heard this is possible with ObjDBX, but I'm not sure how.

 

Thanks for the help.

Shawn

Posted

Hi,

 

Thanks for the help, I tried your solution, and it has the same problem as the other zoom and regen solutions. They all require that the screensize sysvar be reset, but it won't happen until you have completely left AutoLISP, and are sitting back at the command prompt. I have provided the Window resize function and a small test function to highlight the problem.

 

(defun ACADWindowSize (Width Height Doc_ID /)
(vla-put-width Doc_ID Width);1660
(vla-put-height Doc_ID Height);1059
(Print)(princ "Window Set: ")
;(vla-put-windowstate Doc_ID acMax)
;(vla-put-windowstate Doc_ID acNorm)
); ACADWindowSize
;
;
;
(defun test ()
(setq Doc_ID (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(ACADWindowSize 830 564 Doc_ID);1660 1059 +34 for Top and Bottom headers
(vla-zoomextents (vlax-get-acad-object))
(print)(princ (getvar "SCREENSIZE"))
(print)(Prompt "Press enter to Exit. ")(print)
(getpoint)
)

 

Let me know if you can think of something I missed.

 

Thanks again for your help, and happy new year.

Shawn

Posted

if you split the function in two and use the vla-sendcommand

 

Example:

 

 (defun t1()
   (setvar "sysvarname" val)
   (setq adoc (vla-get-activedocument(vlax-get-acad-object))
   (vla-sendcommand  adoc "(t2)\r")
 )

 (defun t2()
   Do something......
 )

 

this will exit the lisp function before it starts the second

 

alternatively use the function to send "setvar\rscreensize\rvalue\r" or something to that effect

 

hope that helps

Ollie

Posted

Hi,

 

Unfortunately I tried that with no luck. Vla-sendcommand is like (command) in straight LISP, it will allow you to run an ACAD command, but is not truely the command line, you are still in LISP. You are not out of LISP until you return from vla-sendcommand and exit T1.

 

The screensize sysvar will not update until then, and unfortunately it is read only, so I can't just set it.

 

Maybe Lee has an idea, but I'm thinking I may need to write my first piece of ARX code to set this before the drawing is opened.

 

Thanks again for your help.

 

Have a good one.

Shawn

Posted
Hi,

 

Unfortunately I tried that with no luck. Vla-sendcommand is like (command) in straight LISP, it will allow you to run an ACAD command, but is not truely the command line, you are still in LISP. You are not out of LISP until you return from vla-sendcommand and exit T1.

 

I have tested the following

(defun test()
 (princ  "OLD: ") (princ (getvar "screensize"))
 (setq adoc(vla-get-activedocument(vlax-get-acad-object)))
 (vla-put-height adoc 800)
 (vla-regen adoc acactiveviewport)
 (princ "\nNEW: ")
 (vla-sendcommand adoc "(test2)\r")
)
(defun test2()
 (princ  "\NEW ") (princ (getvar "screensize"))
)

I have tried the same without the vla-sendcommand without any luck

 

You will need to take width/height aspect ratio into consideration though

 

Didn't realise the system variable was read only, however the vla-sendcommand runs asynchronously from the function that calls it and won't be deployed until the list function is ended. For example

 (defun sample1()
   (setq adoc(vla-get-activedocument(vlax-get-acad-object)))
   (vla-sendcommand adoc "(alert \"1\")\r")
   (alert "2")
 )

I wouldn't condone using the vla-sendcommand function but it is a suitable workaround. I used to use it to jump between vba and autolisp in the my acad programming early days:)

 

EDIT: The vla-regen statement might not be necessary. I tried that before I added vla-put-height. you may get away with the following

 

vla-put-height

vla-sendcommand

 

Hope this helps

Ollie

Posted

Hi,

 

Well here is what I learned. When using vla-sendcommand on the active drawing, AutoCAD will not execute the sendcommand until the routine that called it finishes.

 

(defun test()
 (princ  "OLD: ") (princ (getvar "screensize"))
 (setq adoc(vla-get-activedocument(vlax-get-acad-object)))
 (vla-put-height adoc 800)
 (vla-regen adoc acactiveviewport)
;  (princ "\nNEW: ")
 (vla-sendcommand adoc "(test2)\r")
(print)(prompt "Beating yourhead against a wall is fun. \n")
)

(defun test2()
 (princ  "\NEW ") (princ (getvar "screensize"))
)

 

If you look at what happens, it gets all the way to the end of the calling routine before it executes. Close but no cigar.

 

Thanks again.

Shawn

Posted
Hi,

 

Well here is what I learned. When using vla-sendcommand on the active drawing, AutoCAD will not execute the sendcommand until the routine that called it finishes.

 

If you look at what happens, it gets all the way to the end of the calling routine before it executes. Close but no cigar.

 

Thanks again.

Shawn

 

I must be misinterpreting the question:

 

;Excerpt from command line console--
Command: (defun test(i)
(_>   (princ  "OLD: ") (princ (getvar "screensize"))
(_>   (setq adoc(vla-get-activedocument(vlax-get-acad-object)))
(_>   (vla-put-height adoc i)
(_>   (vla-regen adoc acactiveviewport)
(_>   (vla-sendcommand adoc "(test2)\r")
(_> )
TEST
Command: (defun test2()
(_>   (princ  "\NEW ") (princ (getvar "screensize"))
(_> )
TEST2
Command: (test 300)
OLD: (1247.0 446.0)Regenerating model.
Command: nil
Command: (test2)
NEW (1247.0 246.0)(1247.0 246.0)

Height difference 200.0

Ergo the value has been update in between functions

 

Is that not what your hoping to achieve?

 

With that said you'll probably need to take height of the command console into consideration to calculate the change you require

 

Ollie

Posted

Hello again,

 

If you run what I posted last you will notice that (test2) is executed after the message, even though it is called before the meesage is sent to the command line.

 

What that means is if you run a routine that sends a vla-command to the current drawing, the vla-command will not run until the rest of the calling routine finishes. You can see an example below, note how the message executed before the vla-sendcommand.

 

Command: (test)

OLD: (1478.0 753.0)Regenerating model.

 

Command:

Beating yourhead against a wall is fun.

nil

 

Command: (test2)

NEW (1478.0 753.0)(1478.0 753.0)

 

This may have to do with the way my batch routine runs, it never leaves LISP in the processed drawings. It works like so:

 

* Drawing1 runs batch routine.

* Batch opens drawing to be worked on.

* S::Start-up looks for LISPs to execute and does so. (everything I do happens here.)

* S::Start-up ends and focus shifts back to drawing1.

* Drawing is saved.

* Next drawing.

 

I have noticed that if I send a command from drawing1 to the work drawing focus shifts and stays with the work drawing. This is bad for my routine.

 

Thanks again, if I ever get a solution I'll send it to you.

Shawn

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...