<?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: setting layers based on object selection in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949984#M66194</link>
    <description>&lt;P&gt;Yes!&amp;nbsp; I would like to incorporate door size and openangle, which are both dynamic values in the door block.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2020 21:46:46 GMT</pubDate>
    <dc:creator>shillmanB5QQZ</dc:creator>
    <dc:date>2020-12-18T21:46:46Z</dc:date>
    <item>
      <title>setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949807#M66185</link>
      <description>&lt;P&gt;Definite LISP newbie.&amp;nbsp; This is my first.&amp;nbsp; I know, big undertaking.&amp;nbsp; I have been working this lisp routine that you select the wall, select point on wall for the start of the break, select door width and a point on perpendicular line and it will break both lines and draw the ends of the walls in on the correct layer, and inserts the door block on the correct layer.&amp;nbsp; I have 4 possible scenarios for the wall layers, (EXST-WALL-INTR, EXST-WALL EXTER, NEW-WALL-INTR, NEW-WALL-EXTR) and 4 scenarios for the door layer (EXST-DOOR-EXTR, EXST-DOOR-INTR, NEW-DOOR-EXTR, NEW-DOOR-INTR )&amp;nbsp; I have accomplished this task . . . .&amp;nbsp; to an extent.&amp;nbsp; I have figured out setting the wall layers.&amp;nbsp; The issue is having 4 possibilities of door layers based on what wall layer is picked.&amp;nbsp; &amp;nbsp;I have made 2 lisp routines, one for existing and one for new.&amp;nbsp; I would like to have one routine for all scenarios.&amp;nbsp; I am wonder if there is a way to to have one routine (Door.lisp) that can process all existing and new conditions and set appropriate layers.&amp;nbsp; I have found help from various sites on the internet to put this routine together but can seem to find an answer to what I am looking for.&amp;nbsp; Hence the reason for this post.&amp;nbsp; Here is what I have found, pieced together and figured out so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;Program to cut door opening in wall and insert door on correct layer -- DoorExst.lsp&lt;BR /&gt;(defun c:doorexst (/ pt1 pt2 pt3 pt4 ang1 ang2 dst1 osnap1 str1 clyr wlyr bfind msg)&lt;BR /&gt;(setvar "cmdecho" 0)&lt;BR /&gt;(command "-purge" "b" "door" "n")&lt;BR /&gt;(setq osnap1 (getvar "osmode"))&lt;BR /&gt;(setq clyr (getvar "clayer"))&lt;BR /&gt;(defun *error* (msg)&lt;BR /&gt;(setvar "osmode" osnap1)&lt;BR /&gt;(setvar "clayer" clyr)&lt;BR /&gt;(princ msg)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;BR /&gt;(setvar "osmode" 512) ;nearest osnap mode&lt;BR /&gt;(setq wlyr (entget (car (entsel "\nSelect Wall: "))));end setq&lt;BR /&gt;(setq pt1 (getpoint "\nSelect point on wall to start point of opening: ")) ;get first break point&lt;BR /&gt;(setq pt2 (getpoint pt1 "\nEnter endpoint of opening: ")) ;get second break point&lt;BR /&gt;(setvar "osmode" 128) ;perpend osnap mode&lt;BR /&gt;(setq pt3 (getpoint pt1 "\nSelect opposite side of wall: "));get 2nd line&lt;BR /&gt;(Setvar "osmode" 0) ;no osnap mode&lt;BR /&gt;(setq ang1 (angle pt1 pt3)) ;find angle btwn lines&lt;BR /&gt;(setq dst1 (distance pt1 pt3)) ;find dist. btwn lines&lt;BR /&gt;(setq pt4 (polar pt2 ang1 dst1)) ;derive pt4 on 2nd line&lt;BR /&gt;(setq ang2 (* (angle pt1 pt2)57.2958)) ;find angle for door insertion&lt;BR /&gt;(setvar "clayer" (cdr (assoc 8 wlyr);end set current layer&lt;BR /&gt;(command&lt;BR /&gt;"break" pt1 pt2 ;break 1st line&lt;BR /&gt;"break" pt3 pt4 ;break 2nd line&lt;BR /&gt;"line" pt1 pt3 "" ;close ends of lines&lt;BR /&gt;"line" pt2 pt4 ""&lt;BR /&gt;);end command&lt;BR /&gt;(defun intr ()&lt;BR /&gt;(setvar "clayer" "exst-door-intr")&lt;BR /&gt;);end intr&lt;BR /&gt;(defun extr ()&lt;BR /&gt;(setvar "clayer" "exst-door-extr")&lt;BR /&gt;);end extr&lt;BR /&gt;(initget "Exterior Interior");end initget&lt;BR /&gt;(setq str1 (getkword "Is this an Exterior or Interior door?&amp;lt;Exterior/Interior&amp;gt;:"));end str1&lt;BR /&gt;(if (= str1 "Exterior")&lt;BR /&gt;(extr)&lt;BR /&gt;(intr)&lt;BR /&gt;);end if&lt;BR /&gt;(defun bfind (/ bfind)&lt;BR /&gt;(setq bfind (tblsearch "block" "standards"))&lt;BR /&gt;(if (not bfind)(command "-insert" "standards.dwg=" "0,0" "" "" ""))&lt;BR /&gt;(princ "Standards is already inserted. ")&lt;BR /&gt;(command "_.erase" "l" "")&lt;BR /&gt;);end bfind&lt;BR /&gt;(bfind)&lt;BR /&gt;(princ)&lt;BR /&gt;(command "-insert" "door" pt3 1 1 ang2)&lt;BR /&gt;(command "draworder" "l" "" "b")&lt;BR /&gt;(setvar "clayer" clyr)&lt;BR /&gt;(setvar "osmode" osnap1)&lt;BR /&gt;(setvar "cmdecho" 1)&lt;BR /&gt;(princ)&lt;BR /&gt;);end doorexst&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&amp;nbsp; Also, I know the structure is probably less than desirable.&amp;nbsp; All suggestions on lisp structure are welcome as well.&amp;nbsp; New to these forums, if this needs to be move to a more appropriate location feel free to move.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:06:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949807#M66185</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T20:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949845#M66186</link>
      <description>Why don't you just install and run AutoCAD-ARCHITECTURE? Its free with every AutoCAD subscription for the past 2+versions now, it does all that, plus so much more, and you get actual smart doors/walls/ceilings/roofs etc. to boot.&lt;BR /&gt;&lt;BR /&gt;Explore here &lt;A href="https://www.autodesk.com/products/autocad/included-toolsets/autocad-architecture" target="_blank"&gt;https://www.autodesk.com/products/autocad/included-toolsets/autocad-architecture&lt;/A&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:21:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949845#M66186</guid>
      <dc:creator>pendean</dc:creator>
      <dc:date>2020-12-18T20:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949851#M66187</link>
      <description>&lt;P&gt;Unfortunately that is not my call.&amp;nbsp; The firm I work for is still on AutoCAD 2010.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:25:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949851#M66187</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T20:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949878#M66188</link>
      <description>&lt;P&gt;Would you post some examples dwg?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:42:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949878#M66188</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-18T20:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949907#M66189</link>
      <description>&lt;P&gt;Here is the example dwg&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:59:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949907#M66189</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T20:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949929#M66190</link>
      <description>&lt;P&gt;Are you able from layer of breaking wall tell the layer of door? Like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you still need to decide whether its interiour or exteriour? Isn't it given by a wall layer?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:13:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949929#M66190</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-18T21:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949958#M66191</link>
      <description>&lt;P&gt;Yes in this program selecting the wall sets the layer for drawing the ends of the walls at the cutout and determining whether the existing door goes on an interior or exterior door layer.&amp;nbsp; &amp;nbsp;Where I am running into trouble is with the new door layers.&amp;nbsp; Being that I am very new to writing lisp and I am having a problem with how to incorporate the NEW doors into this routine.&amp;nbsp; Currently I have one lisp file for existing doors and one lisp file for new doors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:31:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949958#M66191</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T21:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949966#M66192</link>
      <description>&lt;P&gt;Not sure if I do follow... I thought it's all given by layer of cutting wall. anyway, try the code and see...&lt;/P&gt;
&lt;P&gt;BTW don't you want to incorporate the doorsize too?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:door (/ pt1 pt2 pt3 pt4 ang1 ang2 dst1 osnap1 str1 clyr wlyr bfind msg)
  
  (defun *error* (msg)
    (setvar "osmode" osnap1)
    (setvar "clayer" clyr)
    (setvar 'cmdecho 1)
    (princ msg)
    (princ)
    )
    
  (defun createifnot (lay)
    (or (tblsearch "layer" lay)
	(cond ((= lay "EXST-WALL-INTR") (command "_.-layer" "_new" "EXST-WALL-INTR" "_color" "EXST-WALL-INTR" ""))
	      (T (command "_.-layer" "_new" lay ""))))
    lay)
  
  (defun bfind ()
    (if (tblsearch "block" "door")
      (princ "Standards is already inserted. ")
      (command "-insert" "standards.dwg=" "0,0" "" "" ""
	       "_.erase" "l" ""))
    );end bfind

  ; ----------------------------------------------------------------------------------------------------------------------------
  
  (setvar "cmdecho" 0)
  (command "-purge" "b" "door" "n")
  (setq osnap1 (getvar "osmode"))
  (setq clyr (getvar "clayer"))
  
  (setvar "osmode" 512) ;nearest osnap mode
  (setq pt1 (getpoint "\nSelect point on wall to start point of opening: ")) ;get first break point
  (setq wlyr (nentselp pt1))
  (setq pt2 (getpoint pt1 "\nEnter endpoint of opening: ")) ;get second break point
  (setvar "osmode" 128) ;perpend osnap mode
  (setq pt3 (getpoint pt1 "\nSelect opposite side of wall: "));get 2nd line
  
  (setq ang1 (angle pt1 pt3)) ;find angle btwn lines
  (setq dst1 (distance pt1 pt3)) ;find dist. btwn lines
  (setq pt4 (polar pt2 ang1 dst1)) ;derive pt4 on 2nd line
  (setq ang2 (* (angle pt1 pt2) 57.2958)) ;find angle for door insertion
  (setq lay (cdr (assoc 8 (entget (car wlyr)))))
  
  (setvar "clayer" lay);end set current layer
  
  (Setvar "osmode" 0) ;no osnap mode
  (command "break" pt1 pt2 ;break 1st line
	   "break" pt3 pt4 ;break 2nd line
	   "line" pt1 pt3 "" ;close ends of lines
	   "line" pt2 pt4 ""
	   );end command
  
  ;;;  (initget "Exterior Interior");end initget
  ;;;  (setq str1 (getkword "Is this an Exterior or Interior door?&amp;lt;Exterior/Interior&amp;gt;:"));end str1
  ;;;  (if (= str1 "Exterior")
  ;;;    (extr)
  ;;;    (intr)
  ;;;    );end if
  (bfind)
  (setq lay (vl-string-subst "DOOR" "WALL" lay))
  (setvar 'clayer (createifnot lay))
  
  (command "-insert" "door" pt3 1 1 ang2)
  (command "draworder" "l" "" "b")
  (setvar "clayer" clyr)
  (setvar "osmode" osnap1)
  (setvar "cmdecho" 1)
  (princ)
  );end doorexst
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:43:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949966#M66192</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-18T21:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949980#M66193</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/857989i91FCC68A8A0BA188/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:45:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949980#M66193</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T21:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949984#M66194</link>
      <description>&lt;P&gt;Yes!&amp;nbsp; I would like to incorporate door size and openangle, which are both dynamic values in the door block.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:46:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949984#M66194</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T21:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949995#M66195</link>
      <description>&lt;P&gt;I tried what you posted and got this . . . .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command: DOOR&lt;BR /&gt;No unreferenced blocks found.&lt;/P&gt;&lt;P&gt;Select point on wall to start point of opening:&lt;BR /&gt;Enter endpoint of opening:&lt;BR /&gt;Select opposite side of wall: No object found&lt;BR /&gt;No object found&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;*Invalid selection*&lt;BR /&gt;Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon&lt;BR /&gt;Function cancelledSelect object: *Cancel*&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:51:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9949995#M66195</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-18T21:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9950039#M66196</link>
      <description>&lt;P&gt;Now you show up. Find the line causing this trouble!&lt;/P&gt;
&lt;P&gt;btw it works for me.&lt;/P&gt;
&lt;DIV id="gtx-trans" style="position: absolute; left: 255px; top: 31.8px;"&gt;
&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Dec 2020 22:06:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9950039#M66196</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-18T22:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9950121#M66197</link>
      <description>&lt;P&gt;Here's the code. I'm not versed with imperials... so test it yourself better.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, have a bit issues with degree sigh of yours... "Closed" vis state works, but not the others. Either find and use the ascii num or rename the states. Good luck&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW *error* func has to be localized!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(vl-load-com)

(defun c:door (/ *error* cly cmd osm pt1 pt2 pt3 pt4 ang1 ang2 ent lay bfind ang)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cmd (setvar 'cmdecho cmd))
    (if osm (setvar 'osmode  osm))
    (if cly (setvar 'clayer  cly))
    (princ))
  
  (defun createifnot (lay)
    (or (tblsearch "layer" lay)
	(cond ((= lay "EXST-WALL-INTR") (command "_.-layer" "_new" "EXST-WALL-INTR" "_color" "EXST-WALL-INTR" ""))
	      (T (command "_.-layer" "_new" lay ""))))
    lay)
  
  (defun bfind ()
    (if (tblsearch "block" "door")
      (princ "Standards is already inserted. ")
      (command "-insert" "standards.dwg=" "0,0" "" "" ""
	       "_.erase" "l" ""))
    );end bfind
  
  ; ----------------------------------------------------------------------------------------------------------------------------
  
  (setq cmd (getvar 'cmdecho)) (setvar "cmdecho" 0)
  (command "-purge" "b" "door" "n")
  (setq osm (getvar "osmode"))
  (setq cly (getvar "clayer"))
  
  (setvar "osmode" 512) ;nearest osnap mode
  (setq pt1 (getpoint "\nSelect point on wall to start point of opening: ")) ;get first break point
  (setq ent (car (nentselp pt1)))
  (setvar "osmode" 128) ;perpend osnap mode
  (setq pt3 (getpoint pt1 "\nSelect opposite side of wall: "));get 2nd line
  
  (or *d-siz*
      (setq *d-siz* 36))
  (setq *d-siz* (cond ((getdist pt1 (strcat "\nDoor size &amp;lt;" (rtos *d-siz*) "&amp;gt;: ")))
		      (*d-siz*)))

  (or *d-ang*
      (setq *d-ang* "30"))
  (initget "30 45 60 90 0 Closed")
  (setq *d-ang* (cond ((getkword (strcat "\nOpening Angle [Closed] &amp;lt;" *d-ang* "&amp;gt;: ")))
		      (*d-ang*)))
  (setq ang (cond ((= "0" *d-ang*) 	"Closed")
		  ((= "Closed" *d-ang*) "Closed")
		  (T 			(strcat "Open " *d-ang* "o"))))
  
  (setq ang1 (angle pt1 pt3))
  (setq ang2 (- ang1 (/ pi 2))) ;find angle for door insertion
  (setq pt2 (polar pt1 ang2 *d-siz*))
  (setq pt4 (polar pt2 ang1 (distance pt1 pt3))) ;derive pt4 on 2nd line
  
  (setq lay (cdr (assoc 8 (entget ent))))
  
  (setvar "osmode" 0) ;no osnap mode
  (command "break" pt1 pt2 ;break 1st line
	   "break" pt3 pt4) ;break 2nd line
  
  (setvar "clayer" lay);end set current layer
  (command "line" pt1 pt3 "" ;close ends of lines
	   "line" pt2 pt4 ""
	   );end command
  
  (bfind)
  (setq lay (vl-string-subst "DOOR" "WALL" lay))
  (setvar 'clayer (createifnot lay))
  
  (command "-insert" "door" pt3 1 1 ang2)
  (LM:SetDynPropValue (vlax-ename-&amp;gt;vla-object (entlast)) "DoorSize" *d-siz*)
  (LM:SetVisibilityState (vlax-ename-&amp;gt;vla-object (entlast)) ang)
  
  (command "draworder" "l" "" "b")
  (*error* "end")
  );end doorexst








;; Block Name  -  Lee Mac
;; Returns the true (effective) name of a supplied block reference

(defun LM:blockname ( obj )
  (if (vlax-property-available-p obj 'effectivename)
    (defun LM:blockname ( obj ) (vla-get-effectivename obj))
    (defun LM:blockname ( obj ) (vla-get-name obj))
    )
  (LM:blockname obj)
  )

;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(defun LM:setdynpropvalue ( blk prp val )
  (setq prp (strcase prp))
  (vl-some
    '(lambda ( x )
       (if (= prp (strcase (vla-get-propertyname x)))
	 (progn
	   (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
	   (cond (val) (t))
	   )
	 )
       )
    (vlax-invoke blk 'getdynamicblockproperties)
    )
  )

;; Get Dynamic Block Property Value  -  Lee Mac
;; Returns the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)

(defun LM:getdynpropvalue ( blk prp )
  (setq prp (strcase prp))
  (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
	   (vlax-invoke blk 'getdynamicblockproperties)
	   )
  )


;; Get Dynamic Block Properties  -  Lee Mac
;; Returns an association list of Dynamic Block properties &amp;amp; values.
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [lst] Association list of ((&amp;lt;prop&amp;gt; . &amp;lt;value&amp;gt;) ... )

(defun LM:getdynprops ( blk )
  (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value)))
	  (vlax-invoke blk 'getdynamicblockproperties)
	  )
  )


;; Get Dynamic Block Property Allowed Values  -  Lee Mac
;; Returns the allowed values for a specific Dynamic Block property.
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; Returns: [lst] List of allowed values for property, else nil if no restrictions

(defun LM:getdynpropallowedvalues ( blk prp )
  (setq prp (strcase prp))
  (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues)))
	   (vlax-invoke blk 'getdynamicblockproperties)
	   )
  )


;; Get Visibility Parameter Name  -  Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [str] Name of Visibility Parameter, else nil

(defun LM:getvisibilityparametername ( blk / vis )
  (if
    (and
      (vlax-property-available-p blk 'effectivename)
      (setq blk
	     (vla-item
	       (vla-get-blocks (vla-get-document blk))
	       (vla-get-effectivename blk)
	       )
	    )
      (= :vlax-true (vla-get-isdynamicblock blk))
      (= :vlax-true (vla-get-hasextensiondictionary blk))
      (setq vis
	     (vl-some
	       '(lambda ( pair )
		  (if
		    (and
		      (= 360 (car pair))
		      (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair)))))
		      )
		    (cdr pair)
		    )
		  )
	       (dictsearch
		 (vlax-vla-object-&amp;gt;ename (vla-getextensiondictionary blk))
		 "ACAD_ENHANCEDBLOCK"
		 )
	       )
	    )
      )
    (cdr (assoc 301 (entget vis)))
    )
  )


;; Get Dynamic Block Visibility State  -  Lee Mac
;; Returns the value of the Visibility Parameter of a Dynamic Block (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [str] Value of Visibility Parameter, else nil

(defun LM:getvisibilitystate ( blk / vis )
  (if (setq vis (LM:getvisibilityparametername blk))
    (LM:getdynpropvalue blk vis)
    )
  )

;; Set Dynamic Block Visibility State  -  Lee Mac
;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
;; blk - [vla] VLA Dynamic Block Reference object
;; val - [str] Visibility State Parameter value
;; Returns: [str] New value of Visibility Parameter, else nil

(defun LM:SetVisibilityState ( blk val / vis )
  (if
    (and
      (setq vis (LM:getvisibilityparametername blk))
      (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis)))
      )
    (LM:setdynpropvalue blk vis val)
    )
  )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 22:50:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9950121#M66197</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-12-18T22:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954041#M66198</link>
      <description>&lt;P&gt;Thank you for the help.&amp;nbsp; All the layering is working great.&amp;nbsp; I am having issues with the "OpenAngle" value of the door block, and the rotation angle during block insertion.&amp;nbsp; I tried making some adjustments to the lisp and&amp;nbsp; totally messed up the routine.&amp;nbsp; Here is what I am getting when I try inserting a door on any angle wall other than a horizontal wall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/858605iCEBEFCB6C90DE378/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 15:32:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954041#M66198</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-21T15:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954121#M66199</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;Here is a new Sample dwg with the block "openangle" values updated without the degree symbol.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 16:05:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954121#M66199</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-21T16:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954125#M66200</link>
      <description>&lt;P&gt;Here is example drawing&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 16:08:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954125#M66200</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-21T16:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954201#M66201</link>
      <description>&lt;P&gt;I am looking at this line:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;FONT color="#000000"&gt;(command "-insert" "door" pt3&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;1 1&lt;/FONT&gt;&lt;FONT color="#000000"&gt; ang2)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which includes both X and Y scale factors.&amp;nbsp; When I Insert your Door Block manually, even though it doesn't claim to be defined for uniform scaling, as a dynamic Block it wants only one.&amp;nbsp; The ones in your sample drawing have rotation angles listed in Properties &lt;EM&gt;at the directions of the wall Lines&lt;/EM&gt;, but something about their being dynamic must be why they don't look like it.&amp;nbsp; [I'm not well versed in dynamic Blocks, so others could advise better than I.]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;At least &lt;EM&gt;try&lt;/EM&gt; taking the second scale factor out:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;FONT color="#000000"&gt;(command "-insert" "door" pt3&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt; ang2)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 16:36:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954201#M66201</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-12-21T16:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954357#M66202</link>
      <description>&lt;P&gt;Thanks Kent1cooper,&amp;nbsp; I redefined the block to scale uniformly and took away a "1".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(command "-insert" "door" pt3 1 ang2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now when I run the routine the first door (horizontal wall) is inserting correctly, 0 rotation.&amp;nbsp; The second door I inert, the one in the angled wall, is inserting at a rotation angle of 1 instead of "ang2", and the third time I try and insert the door (vertical wall) the door inserts at a rotation angle of 2 degrees.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/858665i113678C08C041F7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, the "AngleOpen" value in the block is not working either.&amp;nbsp; The prompt is only reading 90, closed.&amp;nbsp; 90 is not working closed is working.&amp;nbsp; The prompt should read " 30, 45, 60, 90, Closed".&amp;nbsp; If I try and change that the routine fails to work.&amp;nbsp; Sorry to be such a pain.&amp;nbsp; &amp;nbsp;I have not worked with either of the "OR" function, the "COND" function nor the "nentselp".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very bizarre!&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 17:43:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954357#M66202</guid>
      <dc:creator>shillmanB5QQZ</dc:creator>
      <dc:date>2020-12-21T17:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954397#M66203</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10085198"&gt;@shillmanB5QQZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;....&amp;nbsp; The second door I inert, the one in the angled wall, is inserting at a rotation angle of 1 instead of "ang2", and the third time I try and insert the door (vertical wall) the door inserts at a rotation angle of 2 degrees.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;....&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;On that issue, they're &lt;EM&gt;not&lt;/EM&gt; at 1 and 2 degrees -- those are only rounded-for-display values.&amp;nbsp; [This is why I never have angular values displayed to the nearest whole degree.]&amp;nbsp; They are the directions of the Lines, in degrees but with the &lt;EM&gt;numerical&amp;nbsp;value&lt;/EM&gt; of the angles&amp;nbsp;&lt;EM&gt;in radians&lt;/EM&gt;.&amp;nbsp; If you're using &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp;'s code, ang2 is still in radians when the Insert happens.&amp;nbsp; Your original had a multiplier to convert the angle between points to degrees [there's a more precise way, but that could be close enough for your purposes].&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 18:17:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954397#M66203</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-12-21T18:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: setting layers based on object selection</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954416#M66204</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10085198"&gt;@shillmanB5QQZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;....&amp;nbsp;&lt;/SPAN&gt;Also, the "AngleOpen" value in the block is not working either.&amp;nbsp; The prompt is only reading 90, closed.&amp;nbsp; 90 is not working closed is working.&amp;nbsp; The prompt should read " 30, 45, 60, 90, Closed".&amp;nbsp; If I try and change that the routine fails to work.&amp;nbsp; .... &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I expect if you typed in one of those other values, it should "get" it.&amp;nbsp; But to be able to &lt;EM&gt;pick them from the prompt&lt;/EM&gt;, they would need to be included in it, something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;..."\nOpening Angle [30/45/60/90/0/Closed] &amp;lt; ....&lt;/LI-CODE&gt;
&lt;P&gt;[I haven't fully traced through what that gets used for.]&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 18:15:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/setting-layers-based-on-object-selection/m-p/9954416#M66204</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-12-21T18:15:43Z</dc:date>
    </item>
  </channel>
</rss>

