Author Topic: Plot Style from a Layer ??  (Read 4965 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« 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?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #1 on: December 04, 2004, 02:42:38 PM »
Here's my idea, from the help file on Layer Table objects:
390 Hard pointer ID/handle of PlotStyleName object
So:
Code: [Select]
(setq layEnt (entget (tblobjname "layer" "0")))
(setq pltStyl (entget (cdr (assoc 390 layEnt))))

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Plot Style from a Layer ??
« Reply #2 on: December 04, 2004, 02:55:23 PM »
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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« Reply #3 on: December 04, 2004, 03:00:39 PM »
I got this on the web:
Code: [Select]
(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've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Plot Style from a Layer ??
« Reply #4 on: December 04, 2004, 03:19:23 PM »
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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #5 on: December 04, 2004, 03:27:59 PM »
Quote from: Keith
....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.....
Code: [Select]

(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?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Plot Style from a Layer ??
« Reply #6 on: December 04, 2004, 03:35:30 PM »
that might work indeed
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« Reply #7 on: December 04, 2004, 03:36:01 PM »
Jeff,
Thanks for the help..

This is what I get from PltStyl
Code: [Select]
((-1 . <Entity name: 1bb3930>)
  (0 . "ACDBPLACEHOLDER")
  (5 . "26")
  (102 . "{ACAD_REACTORS")
  (330 . <Entity name: 1bb3830>)
  (102 . "}")
  (330 . <Entity name: 1bb3830>)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« Reply #8 on: December 04, 2004, 03:38:34 PM »
Oooooh the old edit trick :)

That did it.
Thanks Jeff :D
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #9 on: December 04, 2004, 03:38:34 PM »
Removed stuff that CAB had already found......

You're welcome  :mrgreen:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« Reply #10 on: December 04, 2004, 03:46:01 PM »
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.

Code: [Select]
_$ (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've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #11 on: December 04, 2004, 03:59:11 PM »
I know, I know.......brb   That's what happens when I try it in a test drawing with only 1 layer & 1 plotstyle......

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #12 on: December 04, 2004, 04:04:46 PM »
This should do it:
Code: [Select]

(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)))))
    )
  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Plot Style from a Layer ??
« Reply #13 on: December 04, 2004, 04:08:18 PM »
Hey you beat me to it.. Good job.

Code: [Select]
(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)))
  )
)
« Last Edit: June 21, 2016, 08:11:45 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Plot Style from a Layer ??
« Reply #14 on: December 04, 2004, 04:10:03 PM »
And with standard lisp, change my (setq pos...) line to this:
(setq pos (- (length pltstyltbl) (length (member (cons 350 (cdr (assoc 390 layEnt))) pltstyltbl))))

Peter2

  • Swamp Rat
  • Posts: 650
Re: Plot Style from a Layer ??
« Reply #15 on: June 21, 2016, 04:53:30 AM »
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
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23