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

Set PSLTSCALE help

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
420 Views, 11 Replies

Set PSLTSCALE help

I am trying to write a function to change all the layouts to PSLTSCALE = 0
Below is what I have so far BUT IT DOESN'T WORK!!! I think I am supposed to change this:
(100 . "AcDbLayout") (1 . "Layout1") (70 . 1)
to this:
(100 . "AcDbLayout") (1 . "Layout1") (70 . 0)
but I don't know how to access the (100 . "AcDbLayout") part of the entity data. SEE BELOW

Let me know if I am barking completely up the wrong tree.
And thanks...

[CODE]

(defun acad-object ()
(cond (*acad-object*) ; Return the cached object
(t
(setq *acad-object* (vlax-get-acad-object))
)
)
)

(defun active-document ()
(cond (*active-document*) ; Return the cached object
(t
(setq *active-document* (vla-get-activedocument (acad-object)))
)
)
)

(defun ppn_set_psltscale (LAYOUTS PS_LTSC / my_layout_ob my_layout_en EN_DATA)

(foreach LAYOUT LAYOUTS
(progn
(setq my_layout_ob (vla-item (vla-get-layouts (active-document)) LAYOUT))
(setq my_layout_en (vlax-vla-object->ename my_layout_ob))
(setq EN_DATA (entget my_layout_en))
(setq EN_DATA (subst (cons 70 PS_LTSC) (assoc 70 EN_DATA) EN_DATA))
(entmod EN_DATA)
)
)
)

(defun c:pslts ( / *acad-object* *active-document*)
(ppn_set_psltscale (layoutlist) 0)
)

[/CODE]

EN_DATA =
((-1 . ) (0 . "LAYOUT") (5 . "3829C") (102 .
"{ACAD_XDICTIONARY") (360 . ) (102 . "}") (102 .
"{ACAD_REACTORS") (330 . ) (102 . "}") (330 .
name: 7ef56c70>) (100 . "AcDbPlotSettings") (1 . "11x17") (2 .
"HP5000-South.pc3") (4 . "11x17") (40 . 4.23333) (41 . 4.23334) (42 . 8.46667)
(43 . 4.23334) (44 . 279.4) (45 . 431.8) (46 . 0.0) (47 . 0.0) (48 . 0.0) (49 .
0.0) (140 . 0.0) (141 . 0.0) (142 . 1.0) (143 . 1.0) (70 . 0) (72 . 1) (73 . 1)
(74 . 1) (7 . "RJC HP DesignJet 1050 100% TransBond.ctb") (75 . 0) (147 . 1.0)
(76 . 0) (77 . 2) (78 . 300) (148 . 0.0131826) (149 . 0.00854427) (100 .
"AcDbLayout") (1 . "Layout1") (70 . 1) (71 . 1) (10 0.0 0.0 0.0) (11 12.0 9.0
0.0) (12 0.0 0.0 0.0) (14 1.0e+020 1.0e+020 1.0e+020) (15 -1.0e+020 -1.0e+020
-1.0e+020) (146 . 0.0) (13 0.0 0.0 0.0) (16 1.0 0.0 0.0) (17 0.0 1.0 0.0) (76 .
0) (330 . ) (331 . ))
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

Hi Sherm!
----------

I'll try to help you but I have one question:

Why do you use VL methods? Is it essentially to you? ; )

I give you the example how to get this info with pure AutoLISP
and you will made changes to modify PSLTSCALE:

;; =================================================================
;; Example: (getpsltscale (getvar "ctab"))
;; =================================================================
(defun getpsltscale ( layout_name / getlayoutinfo layoutinfo
layout_psltscale)

;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(defun getlayoutinfo ( layout_name / allayouts cps_en cps_elist )
(setq allayouts (dictsearch (namedobjdict) "acad_layout"))
(setq cps_en (cdr (assoc 350 (member (cons 3 layout_name)
allayouts))))
(setq cps_elist (entget cps_en))
cps_elist
) ; - 'defun'
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq layoutinfo (getlayoutinfo layout_name))

;; the "trick" :^) to get the DXF70 of your dream!
(setq layoutinfo (member (cons 100 "AcDbLayout") layoutinfo))

(setq layout_psltscale (cdr (assoc 70 layoutinfo)))

layout_psltscale
) ; - 'defun'
;; =================================================================

Now you have to
- save the beginning of the entire list,
- then modify DXF70,
- then reconstruct the list back,
- then ENTMOD it.

AutoCAD loves you!
--------------------------
Alexander V. Koshman
Message 3 of 12
Anonymous
in reply to: Anonymous

So it seems to do everything its supposed to do but PSLTSCALE doesn't change??!?!?!?!
So there must be something I am missing.
I have put it in the "too hard basket"

The following code seems to work fine. It updates the data for each layout in the drawing to set what I thought was the value for PSLTSCALE....BUT

psltscale doesn't actually change??
If anyone has any ideas what else needs to be done>>>
Otherwise its too hard for me so I give up!.!.!.!

(setq *acad-object* nil) ; Initialize global variable
(setq *active-document* nil) ; Initialize global variable
(defun acad-object ()
(cond (*acad-object*) ; Return the cached object
(t
(setq *acad-object* (vlax-get-acad-object))
)))

(defun active-document ()
(cond (*active-document*) ; Return the cached object
(t
(setq *active-document* (vla-get-activedocument (acad-object)))
)))

(defun model-space ()
(cond (*model-space*) ; Return the cached object
(t
(setq *model-space* (vla-get-modelspace (active-document)))
)))

(defun ppn_set_psltscale (LAYOUTS PS_LTSC / my_layout_ob my_layout_en EN_DATA EN_DATA_SUB EN_DATA_PRE ITEM #)

(foreach LAYOUT LAYOUTS
(progn
(setq my_layout_ob (vla-item (vla-get-layouts (active-document)) LAYOUT))
(setq my_layout_en (vlax-vla-object->ename my_layout_ob))
(setq EN_DATA (entget my_layout_en))
(setq EN_DATA_SUB (member (cons 100 "AcDbLayout") EN_DATA))
(setq EN_DATA_SUB (subst (cons 70 PS_LTSC) (assoc 70 EN_DATA_SUB) EN_DATA_SUB))
(setq # 0)
(while (/= T (equal ITEM '(100 . "AcDbLayout")))
(progn
(setq ITEM (nth # EN_DATA))
(setq EN_DATA_PRE (cons ITEM EN_DATA_PRE))
(setq # (1+ #))
)
)
(setq EN_DATA_PRE (reverse (cdr EN_DATA_PRE)))
(setq EN_DATA (append EN_DATA_PRE EN_DATA_SUB))
(entmod EN_DATA)
(setq EN_DATA_PRE nil EN_DATA_SUB nil)
)))

(defun cslts ()
(ppn_set_psltscale (layoutlist) 0)
(princ)
)
Message 4 of 12
Anonymous
in reply to: Anonymous

Agree!
----------
I did it by myself and discovered that PSLTSCALE of the Layout doesn't
change with ENTMOD...

Just wanted to tell you that! : (

--------------------------
Alexander V. Koshman
Message 5 of 12
old-cadaver
in reply to: Anonymous

Search these forums for CHANGEDLAYOUT.LSP

It changes the PSLTSCALE to 1, but you can modify the reactor to set it to 0 just as easily.
Message 6 of 12
Anonymous
in reply to: Anonymous

From RobertB - AUGI Director

Public Sub ResetPSLTScale()
Dim aLayout As AcadLayout
For Each aLayout In ThisDrawing.Layouts
ThisDrawing.ActiveLayout = aLayout
ThisDrawing.SetVariable "PSLTScale", 0
Next aLayout
ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item("Model")
End Sub
Message 7 of 12
Anonymous
in reply to: Anonymous

Could only find this one and it doesn't even come close.
However I think you have missed the point. The code I posted is attempting to change PSLTSCALE for all layouts in a drawing no matter how many there are without having to switch manually from one to another (in the case of a simple reactor)
Would be much easier to just open a drawing and enter c:pslts and have all layout changed to PSLTSCALE of 1 or 0 as required don't you think?

;; ChangedLayout.lsp
;;
;; changes LTSCALE when switching MODEL/PAPER.

(defun ChangedLayout (reactor layout / )
(if (= (nth 0 layout) "Model") ; else set to 0.5
(setvar "ltscale" (* (setvar "ltscale" 25) 1 ))
(progn
(setvar "ltscale" 0.5)
)
)
)

(if(not *LayoutLTS*)
(setq *LayoutLTS* (VLR-Miscellaneous-Reactor nil '((:VLR-layoutSwitched . ChangedLayout))))
)
;;;
;;;
Message 8 of 12
old-cadaver
in reply to: Anonymous

Ohh, Try this completely untested

(defun c:vppltsc(/ THISTAB VPLST)
(setq THISTAB (getvar "CTAB"))
(foreach LAYOUT (layoutlist)
(setvar "CTAB" LAYOUT)
(setvar psltscale 0)
)
(setvar "CTAB" THISTAB)
(princ)
)
Message 9 of 12
Anonymous
in reply to: Anonymous

Not a bad solution I guess.
For me it was as much a lesson in entity data management as anything else. The whole question was raised by someone else in the AUGI.

Thanks for your input.
Cheers
Sherm
Message 10 of 12
old-cadaver
in reply to: Anonymous

> Not a bad solution I guess.

You guess?? What the heck does that mean??
Message 11 of 12
Anonymous
in reply to: Anonymous

Sorry I meant no offence. It works great.
For me however I was trying to approach it from a direct access point of view and develop a program that would access the dwg data base directly without having to rely on functions like setvar and variables like "CTAB".

Between this forum and AUGI I now have a solution to the original question posted. BUT it was a learning experience for me and I still haven't found out where within the dwg data base the PSLTSCALE is stored for each layout and how to modify it directly. Never mind.

Hypothetically, lets say i wanted to change PSLTSCALE to 1 on 1000 dwg's each with 15 layouts. It would be good not to have to open each one and switch to each layout one by one?!

Now I am not saying I want to do that but as I said it was a learning experience for me.
Again, I do appreciate your input.

Regards
Sherm

PS even the VBA version relies on switching to each layout and changing the scale one by one?.. Message was edited by: Sherm
Message 12 of 12

FWIW,

 

here is the corrected code to change the PSLTSCALE to 0 in all layouts. Quotes were missing in the original in this thread. I tested the code below out and it worked perfectly for me.

 

(defun c:vppltsc(/ THISTAB VPLST)
(setq THISTAB (getvar "CTAB"))
(foreach LAYOUT (layoutlist)
(setvar "CTAB" LAYOUT)
(setvar "psltscale" 0)
)
(setvar "CTAB" THISTAB)
(princ)
)

 

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

Post to forums  

Autodesk Design & Make Report

”Boost