Change the value of a assoc

Change the value of a assoc

cadking2k5
Advocate Advocate
2,035 Views
9 Replies
Message 1 of 10

Change the value of a assoc

cadking2k5
Advocate
Advocate

say I have all this set to psn if I type in (cdr (assoc 72 psn)) 0 (zero) comes up is there a way I can assign a new value to the 72.
((100 . "AcDbPlotSettings") (1 . "") (2 . "None") (4 . "Letter_(8.50_x_11.00_Inches)") (40 . 6.35) (41 . 6.35) (42 . 6.35001) (43 . 6.35001) (44 . 215.9) (45 . 279.4) (46 . -6.35) (47 . -6.35) (48 . 0.0) (49 . 0.0) (140 . 0.0) (141 . 0.0) (142 . 1.0) (143 . 96.0) (70 . 674) (72 . 0) (73 . 1) (74 . 5) (7 . "acad.ctb") (75 . 16) (147 . 1.0) (76 . 1) (77 . 2) (78 . 300) (148 . 0.0) (149 . 0.0) (100 . "AcDbLayout") (1 . "Layout1") (70 . 1) (71 . 1) (10 -2.44051e-07 0.0 0.0) (11 11.0 8.5 0.0) (12 0.0 0.0 0.0) (14 1.04955 0.799988 -3.49182e-08) (15 9.45027 7.20002 8.14936e-08) (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 . <Entity name: 27a79fcc280>) (331 . <Entity name: 27a79fcb750>))

0 Likes
2,036 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant

I haven't done this with plot settings rather than entity data, but try this [the way you would do it if 'psn' were an entity data list]:

 

(entmod (setq psn (subst (cons 72 YourNewValue) (assoc 72 psn) psn)))

 

Read about (subst) and (entmod) in the >AutoLisp Reference<.

Kent Cooper, AIA
0 Likes
Message 3 of 10

dlanorh
Advisor
Advisor
(setq psn (subst (cons 72 value) (assoc 72 psn) psn))

put the new integer value in place of the red value text.

 

To update the entity you have to (entmod) it

 

(entmod (subst (cons 72 value) (assoc 72 psn) psn))

or

(setq psn (subst (cons 72 value) (assoc 72 psn) psn))
(entmod psn)

I am not one of the robots you're looking for

0 Likes
Message 4 of 10

john.uhden
Mentor
Mentor

And...

Sometimes you have to (entupd) the entity name after the entmod.

John F. Uhden

0 Likes
Message 5 of 10

cadking2k5
Advocate
Advocate

this here gets all the assooc of the page setup manager and I have tried 
(setq psn (subst (cons 143 96) (assoc 143 psn) psn))
(entmod psn)
(entupd psn)

but it only changes on the assoc list and the the page setup manager dialog box the 143 is the plot scale i can't use the -plot because you have to know what type of plotter is on that computer and I want a command the will work with every computer.
(setq psn (member '(100 . "AcDbPlotSettings")
(dictsearch
(cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT")))
(getvar "ctab")
)
)
)

0 Likes
Message 6 of 10

Moshe-A
Mentor
Mentor

@cadking2k5  hi,

 

to set the plot scale of a page setup it is better to move to ActiveX

here an example:

 

(vlax-for AcDbPlotSettings (vla-get-plotconfigurations (vla-get-activedocument (vla-get-acad-object)))
 (vla-getCustomScale AcDbPlotSettings 'Numerator 'Denominator) ; get pagesetup scale
  
 (cond 
  ((eq (vla-get-ModelType AcDbPlotSettings) :vlax-true)
   (vl-catch-all-apply 'vla-setCustomScale (list AcDbPlotSettings Numerator Denominator)) ; set model space pagesetup scale
  )
  ( t
   (vl-catch-all-apply 'vla-setCustomScale (list AcDbPlotSettings Numerator Denominator)) ; set paper space\layout(s) pagesetup scale
  )
 ); cond
); vlax-for

enjoy

moshe

 

0 Likes
Message 7 of 10

cadking2k5
Advocate
Advocate

it said ; error: no function definition: VLA-GET-ACAD-OBJECT am i suppose to type something it there to replace that

0 Likes
Message 8 of 10

Moshe-A
Mentor
Mentor

add this as top line

 

(vl-load-com) ; load activex support

 

 

0 Likes
Message 9 of 10

cadking2k5
Advocate
Advocate

here is what I have and the plot scale is staying the same it should change to 96 to 1/8" =1'
(vl-load-com)
(vlax-for AcDbPlotSettings (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
(vla-getCustomScale AcDbPlotSettings '12 '0.125)

(cond
((eq (vla-get-ModelType AcDbPlotSettings) :vlax-true)
(vl-catch-all-apply 'vla-setCustomScale (list AcDbPlotSettings 12 0.125))
)
( t
(vl-catch-all-apply 'vla-setCustomScale (list AcDbPlotSettings 12 0.125))
)
)
)

0 Likes
Message 10 of 10

Moshe-A
Mentor
Mentor

test it and it does work for me

 

first create a named page setup (for example 'setup1') and set it scale to 1" = 1'-0"

than:

(setq plotconfig (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))))
(setq AcDbPlotSettings (vla-item plotconfig "setup1"))
(vl-catch-all-apply 'vla-setCustomScale (list AcDbPlotSettings 0.125 12.0))

now check setup1 

 

 

 

 

0 Likes