TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on December 04, 2004, 01:46:34 PM
-
I'm looking for a way to get the Plot Style of a layer in the drawing using plain lisp.
Any ideas?
-
Here's my idea, from the help file on Layer Table objects:
390 Hard pointer ID/handle of PlotStyleName object
So:
(setq layEnt (entget (tblobjname "layer" "0")))
(setq pltStyl (entget (cdr (assoc 390 layEnt))))
-
Jeff that is exactly what I was going to suggest, but it does not work unless you are plotting by layer rather than by entity lineweight or color
-
I got this on the web:
(vl-load-com)
(setq doc (vla-get-activedocument(vlax-get-acad-object))
layobj(vla-item(vla-get-layers doc) "MyLayer"))
(if layobj
(setq style (vla-get-plotstylename layobj))
)
But didn't see a way to do it in plain lisp.
-
I just tried it and evidently there is some serious issues with the online documentation.
The DXF 390 is supposed to point to the plotstyle object and give the handle of the plotstyle itself, along with the description.
-
....unless you are plotting by layer rather than by entity lineweight or color
Isn't that what he'd be looking for then? You don't have a plot style for a layer unless you are plotting with plot styles vs color-dependent styles.....
In the LayerManager dilalog when CTB's are used, the PlotStyle is greyed out and the layer's color is displayed.
So you could do this: modified after some testing.....
(setq layEnt (entget (tblobjname "layer" "0")))
(if (= 0 (getvar "pstylemode"))
(progn
(setq pltStyl (cdr (assoc 3 (entget (cdr (assoc 330 (entget (cdr (assoc 390 layEnt)))))))))
)
(progn
(setq pltStyl (strcat "Color_" (itoa (cdr (assoc 62 layEnt)))))
)
)
Or am I way off since I don't use NamedPlotStyles?
-
that might work indeed
-
Jeff,
Thanks for the help..
This is what I get from PltStyl
((-1 . <Entity name: 1bb3930>)
(0 . "ACDBPLACEHOLDER")
(5 . "26")
(102 . "{ACAD_REACTORS")
(330 . <Entity name: 1bb3830>)
(102 . "}")
(330 . <Entity name: 1bb3830>)
)
-
Oooooh the old edit trick :)
That did it.
Thanks Jeff :D
-
Removed stuff that CAB had already found......
You're welcome :mrgreen:
-
Wait a second... :shock:
that code returns where all the plot style names are stored. So it only
returns the first dxf code 3 it finds.
_$ (assoc 390 layEnt)
(390 . <Entity name: 1bb3930>)
_$
((-1 . <Entity name: 1bb3930>)
(0 . "ACDBPLACEHOLDER")
(5 . "26")
(102 . "{ACAD_REACTORS")
(330 . <Entity name: 1bb3830>)
(102 . "}")
(330 . <Entity name: 1bb3830>)
)
_$
((-1 . <Entity name: 1bb3830>)
(0 . "ACDBDICTIONARYWDFLT")
(5 . "6")
(102 . "{ACAD_REACTORS")
(330 . <Entity name: 1bb3838>)
(102 . "}")
(330 . <Entity name: 1bb3838>)
(100 . "AcDbDictionary")
(280 . 0)
(281 . 1)
(3 . "Heavy")
(350 . <Entity name: 1bb3ba0>)
(3 . "Light")
(350 . <Entity name: 1bb3930>)
(3 . "Medium")
(350 . <Entity name: 1bb3a98>)
(3 . "Normal")
(350 . <Entity name: 1bb3828>)
(3 . "vHeavy")
(350 . <Entity name: 1bb3ba8>)
(3 . "XHeavy")
(350 . <Entity name: 1bb3aa0>)
(3 . "xL_Scrn")
(350 . <Entity name: 1bb6548>)
(3 . "xLight")
(350 . <Entity name: 1bb3ad8>)
(3 . "xxLight")
(350 . <Entity name: 1bb6550>)
(100 . "AcDbDictionaryWithDefault")
(340 . <Entity name: 1bb3828>)
)
-
I know, I know.......brb That's what happens when I try it in a test drawing with only 1 layer & 1 plotstyle......
-
This should do it:
(if (= 0 (getvar "pstylemode"))
(progn
(setq pltStylTbl (entget (cdr (assoc 330 (entget (cdr (assoc 390 layEnt)))))))
(setq pos (vl-position (cons 350 (cdr (assoc 390 layEnt))) pltstyltbl))
(setq pltStyl (cdr (nth (1- pos) pltstyltbl)))
)
(progn
(setq pltStyl (strcat "Color_" (itoa (cdr (assoc 62 layEnt)))))
)
)
-
Hey you beat me to it.. Good job.
(defun c:test ()
(setq layent (entget (tblobjname "layer" "0")))
(setq pltstyldict (entget (cdr (assoc 330 (entget (cdr (assoc 390 layent)))))))
(if (setq tmp (member (cons 350 (cdr (assoc 390 layent))) (reverse pltstyldict)))
(setq pltsty (cdr (assoc 3 tmp)))
)
)
-
And with standard lisp, change my (setq pos...) line to this:
(setq pos (- (length pltstyltbl) (length (member (cons 350 (cdr (assoc 390 layEnt))) pltstyltbl))))
-
Warning: this topic has not been posted in for at least
120 days. 12 years.
Nevertheless - just found it and it is helpful for me. Thank you :-D