<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Lisp: hatching region on current Layer should be on new layer in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255789#M4338</link>
    <description>&lt;P&gt;You are welcome…cheers!!!&lt;/P&gt;</description>
    <pubDate>Sat, 11 Jan 2025 21:47:52 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2025-01-11T21:47:52Z</dc:date>
    <item>
      <title>Lisp: hatching region on current Layer should be on new layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255739#M4335</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;BR /&gt;This Lisp finds a region on the current layer and then creates a hatch.&lt;BR /&gt;This hatching should be placed on the newly created layer.&lt;BR /&gt;But unfortunately the hatching is placed on the current layer.&lt;BR /&gt;Can someone help me further?&lt;BR /&gt;Thank you Tom&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:CreateHatchRegion ()
  (if (setq objLayer (getvar "clayer"))  ; Hole den aktuellen Layer
    (progn
      ;; Hole die Layer-Eigenschaften des aktuellen Layers
      (setq currentLayerData (tblsearch "LAYER" objLayer))
      (setq currentLayerColor (cdr (assoc 62 currentLayerData)))  ; Farbe des aktuellen Layers

      ;; Suche nach einer Region auf dem aktuellen Layer
      (setq sel (ssget "X" (list (cons 8 objLayer) (cons 0 "REGION"))))

      ;; Wenn eine Region gefunden wurde
      (if sel
        (progn
          (setq ent (ssname sel 0))  ; Wähle das erste gefundene Objekt
          
          ;; Erstelle eine SOLID-Schraffur auf der Region
          (command "_hatch" "SOLID" "1" "0" ent "")

          ;; Hole die zuletzt erstellte Schraffur
          (if (setq lastHatch (entlast))
            (progn
              ;; Setze die Transparenz auf 90%
              (command "_CHPROP" lastHatch "" "_transparency" "90" "")
            )
          )

          ;; Generiere den neuen Layernamen (aktueller Layer + "_Schraffur")
          (setq newLayer (strcat objLayer "_Schraffur"))

          ;; Überprüfe, ob der neue Layer bereits existiert
          (if (not (tblsearch "LAYER" newLayer))  ; Wenn der Layer nicht existiert
            (progn
              ;; Erstelle den Layer mit den gleichen Attributen wie der aktuelle Layer
              (command "._LAYER" "M" newLayer "_Color" currentLayerColor "")
            )
          )

          ;; Setze den Layer der Schraffur auf den neuen Layer
          (command "_CHPROP" lastHatch "" "_Layer" newLayer "")
          
          (princ "\nSchraffur mit Transparenz und dem neuen Layer erstellt.")
        )
      )
      (princ "\nKeine Region auf dem aktuellen Layer gefunden.")
    )
    (princ "\nKein aktueller Layer gefunden.")
  )
  (princ)  ; Beende die Ausgabe
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 11 Jan 2025 20:29:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255739#M4335</guid>
      <dc:creator>t_ott</dc:creator>
      <dc:date>2025-01-11T20:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp: hatching region on current Layer should be on new layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255755#M4336</link>
      <description>&lt;P&gt;looks like you're missing an enter on this line of code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;              (command "._LAYER" "M" newLayer "_Color" currentLayerColor "")&lt;/LI-CODE&gt;&lt;P&gt;change to this and it should work:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;              (command "._LAYER" "_M" newLayer "_Color" currentLayerColor "" "")&lt;/LI-CODE&gt;&lt;P&gt;But curious why you need this if statement since there is always a current layer that would exist:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;  (if (setq objLayer (getvar "clayer"))  ; Hole den aktuellen Layer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Also you may want to prefix the following with a period:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command "_.hatch" "SOLID" "1" "0" ent "")&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;(command "_.CHPROP" lastHatch "" "_transparency" "90" "")&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;(command "_.CHPROP" lastHatch "" "_Layer" newLayer "")&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 11 Jan 2025 21:05:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255755#M4336</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-01-11T21:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp: hatching region on current Layer should be on new layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255767#M4337</link>
      <description>Great, thank you very much for that</description>
      <pubDate>Sat, 11 Jan 2025 21:20:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255767#M4337</guid>
      <dc:creator>t_ott</dc:creator>
      <dc:date>2025-01-11T21:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp: hatching region on current Layer should be on new layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255789#M4338</link>
      <description>&lt;P&gt;You are welcome…cheers!!!&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2025 21:47:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-hatching-region-on-current-layer-should-be-on-new-layer/m-p/13255789#M4338</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-01-11T21:47:52Z</dc:date>
    </item>
  </channel>
</rss>

