<?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: Insert a block at the intersection of two lines which come from 4 points in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295057#M3669</link>
    <description>&lt;P&gt;Thank you for response, please see attached cad file and excel.&lt;/P&gt;</description>
    <pubDate>Sun, 02 Feb 2025 06:08:27 GMT</pubDate>
    <dc:creator>Bin2009</dc:creator>
    <dc:date>2025-02-02T06:08:27Z</dc:date>
    <item>
      <title>Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13291071#M3662</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a lot of work for insert a block at the intersection of two lines which come from 4 points. The points coordinates are from a excel table as below first image. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is any lisp can help with the 3 steps to get final result as below second image:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Draw four lines for the boundary,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Draw 2 diagonal lines,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Insert a block in the intersection of the 2 diagonal lines.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can I find it easily? Can I do it with a single command?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bin2009_1-1738254367767.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1461097i7FCB8DE9B2DAC459/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bin2009_1-1738254367767.png" alt="Bin2009_1-1738254367767.png" /&gt;&lt;/span&gt;&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="Bin2009_0-1738254039003.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1461093iC1ACD3FD568AED3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bin2009_0-1738254039003.png" alt="Bin2009_0-1738254039003.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank very much in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 16:27:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13291071#M3662</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-01-30T16:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13291317#M3663</link>
      <description>&lt;P&gt;Look into the&lt;A href="https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-A181D474-F817-4550-86E9-87649262FA8A" target="_blank" rel="noopener"&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt; (inters)&lt;/STRONG&gt; &lt;/FONT&gt;AutoLisp function&lt;/A&gt;.&amp;nbsp; That intersection point can be found with:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;(inters point1 poin3 poin2 point4)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The diagonal Lines are not needed to find it, if that was the only reason for having them.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 18:06:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13291317#M3663</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2025-01-30T18:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13293355#M3664</link>
      <description>&lt;P&gt;Hello Kent,&lt;/P&gt;&lt;P&gt;Thank very much for the inters Autolisp function, I actually not good at write Aitolisp, need figure out how to do it,&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Bin&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 16:47:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13293355#M3664</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-01-31T16:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13293890#M3665</link>
      <description>&lt;P&gt;The inters is a good function to use here, you can also get the midpoint of two points, as your providing 4 points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq mp (mapcar '* (mapcar '+ pt1 pt3) '(0.5 0.5)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a side question how are you getting the information from Excel ? There are ways to read an Excel, use a csv or read it directly from CAD.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 22:16:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13293890#M3665</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-01-31T22:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294170#M3666</link>
      <description>&lt;P&gt;Thanks Sea-Haven for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My idea lisp is can read the 4 points from excel, then draw the 4 outline and 2 diagonal line, and put the block at the intersection points.&lt;/P&gt;&lt;P&gt;In the excel have about 20 sets of 4-points for each kind of block, and I have 8 different blocks, that means I need repeat the same steps over 100 times, that's why I need a lisp.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bin&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 06:00:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294170#M3666</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-01T06:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294427#M3667</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/550060"&gt;@Bin2009&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;lisp is can read the 4 points from excel, then draw the 4 outline and 2 diagonal line, and put the block at the intersection points.....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your image, I assume the last entry in each line is the Block name.&amp;nbsp; Are the first three numbers&amp;nbsp;X, Y &amp;amp; Z coordinates for a Block, or perhaps is the first [having no decimals like the others] some kind of reference, and the second and third numbers X &amp;amp; Y coordinates?&amp;nbsp; If the latter, is the reference to be bypassed, or is it needed somehow for Block insertion?&amp;nbsp; Are lines like that the only contents of the file?&amp;nbsp; Is it a .CSV file type [easy for AutoLisp to read]?&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 12:26:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294427#M3667</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2025-02-01T12:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294828#M3668</link>
      <description>&lt;P&gt;Post a Excel and a matching dwg, if its every 4 rows then reading Excel should be easy. Need your dwg for the blocks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at image looks like 1st row would be header information.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 22:57:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13294828#M3668</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-02-01T22:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295057#M3669</link>
      <description>&lt;P&gt;Thank you for response, please see attached cad file and excel.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 06:08:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295057#M3669</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-02T06:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295061#M3670</link>
      <description>&lt;P&gt;Hello Kent,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your response. Yes the first 3 column are X,Y,Z, they all have decimal, only because the cell width is too short so the decimal didn't show up. the excel is csv file, I already attached it in the below response to Sea-Haven, the last column is the set number for the block, point 1-4 is for cabinet1, point 5-8 is for cabinet 2...., I also attached the final cad file our boss want to see. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 06:16:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295061#M3670</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-02T06:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295266#M3671</link>
      <description>&lt;P&gt;That seems clear enough, except for one thing:&amp;nbsp; the &lt;STRONG&gt;yellow Text&lt;/STRONG&gt; whose value is "0.000" &lt;EM&gt;at all locations&lt;/EM&gt;.&amp;nbsp; Is that a constant [and if so, maybe expendable]?&amp;nbsp; Is it the Z coordinate [that would agree with the .csv file]?&amp;nbsp; Does the labeling not include anything about X &amp;amp; Y?&amp;nbsp; If not, why Z [if that's what it is]?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 11:46:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295266#M3671</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2025-02-02T11:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295357#M3672</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... except for one thing:&amp;nbsp; the &lt;STRONG&gt;yellow Text&lt;/STRONG&gt; whose value is "0.000" &lt;EM&gt;at all locations&lt;/EM&gt;.&amp;nbsp; Is that a constant...?&amp;nbsp; ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, assuming it &lt;EM&gt;is&lt;/EM&gt; a constant, the attached TEST.lsp seems to do it, though the Block at the same scale factor as your sample shows up smaller.&amp;nbsp; The content of the one Text object can be corrected if it's not always supposed to be that.&amp;nbsp; [If it's the Z coordinate, then the code would need to deal with the DIMZIN System Variable to ensure the 3 trailing decimal zeroes show up.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt; &amp;lt;-- EDIT&lt;/STRONG&gt; &lt;/FONT&gt;line to put in your real file path and name.&amp;nbsp; It could be made to ask you to get the file, rather than have that built in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[I do wonder about the color override on the Lines.&amp;nbsp; Could you just assign the right color to the Layer they're on, and leave them as BYLAYER in color?&amp;nbsp; Whether the Layer3 Text objects should be BYLAYER in color and on different Layers is perhaps an iffier question -- I can see having them on the same Layer, but why the different colors?]&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 14:11:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295357#M3672</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2025-02-02T14:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295428#M3673</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/550060"&gt;@Bin2009&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and yet another one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:cabinets (/ text_height h_factor line_spacing_factor cabinet_point csv_id string cabinet_point cabinet_name cabinet_list cabinet_points line_drawn ins_point insert )
  (defun get_point (sub_cabinet) (list (cadr sub_cabinet) (caddr sub_cabinet)))
  (defun put_text (sub_cabinet text_height h_factor line_spacing_factor / text zero_point)
    (mapcar '(lambda (text_string text_point layer color) (setq text (vla-addtext (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
								       text_string (vlax-3d-point text_point) text_height
								       )
								)
	       						(vla-put-alignment text 9)
	       						(vla-put-textalignmentpoint text (vlax-3d-point text_point)) 
	       						(entmod (append (entget (vlax-vla-object-&amp;gt;ename text)) (list (cons 8 layer) (cons 62 color))))
	       )
	    	(list "0.000" (itoa (car sub_cabinet)) (vl-symbol-name (last sub_cabinet)))
	    	(list (setq zero_point (list (+ (* text_height h_factor) (cadr sub_cabinet)) (caddr sub_cabinet)))
		      (list (car zero_point) (+ (cadr zero_point) (* text_height line_spacing_factor)))
		      (list (car zero_point) (- (cadr zero_point) (* text_height line_spacing_factor)))
		)
	    	(list "Layer3" "Layer3" "Layer3")
	    	(list 2 1 3)
	)
  )
  (setq text_height 0.025
	h_factor 1.25
	line_spacing_factor 1.5
	csv_id (open "YOUR_DRIVE:\\YOUR_DIRECTORY\\Point_BlockSample.csv" "r")
  )
  (while (setq string (read-line csv_id))
    (setq cabinet_point (read (strcat "(" (vl-string-translate "," " " string) ")")))
    (cond
      ((or (null cabinet_name) (= cabinet_name (last cabinet_point))) (setq cabinet_points (append cabinet_points (list cabinet_point))))
      (t (setq cabinet_list (append cabinet_list (list cabinet_points)) cabinet_points (list cabinet_point)))
    )
    (setq cabinet_name (last cabinet_point)) 
  )
  (setq cabinet_list (append cabinet_list (list cabinet_points)))
  (close csv_id)
  (foreach cabinet cabinet_list
    (mapcar '(lambda (line) (setq line_drawn (vla-addline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
					 	(vlax-3d-point (car line)) (vlax-3d-point (cadr line))
					 	)
				  )
	       			(entmod (append (entget (vlax-vla-object-&amp;gt;ename line_drawn)) '((8 . "Layer2") (62 . 1))))
	     )
	     (mapcar 'list (setq cabinet_points (mapcar 'get_point cabinet))
		     	   (append (cdr cabinet_points) (list (car cabinet_points)))
		)
	)
    (mapcar '(lambda (line) (setq line_drawn (vla-addline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
					 	(vlax-3d-point (car line)) (vlax-3d-point (cadr line))
					       )
				  )
	       			(entmod (append (entget (vlax-vla-object-&amp;gt;ename line_drawn)) '((8 . "Layer2") (62 . 1))))
	       )
	    (list (list (get_point (car cabinet)) (get_point (caddr cabinet))) (list (get_point (cadr cabinet)) (get_point (cadddr cabinet))))
	)
    (setvar 'cmdecho 0)
    (setq ins_point (inters (get_point (car cabinet)) (get_point (caddr cabinet)) (get_point (cadr cabinet)) (get_point (cadddr cabinet)))
    	  insert (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
		   (vlax-3d-point ins_point) "Cabinet" 1 1 1 0
		   )
	)
    (entmod (append (entget (vlax-vla-object-&amp;gt;ename insert)) '((8 . "Layer1") (62 . 256))))
    (command "_objectscale" (vlax-vla-object-&amp;gt;ename insert) "" "_add" "" "1:500" "")
    (command "_aiobjectscaleremove" (vlax-vla-object-&amp;gt;ename insert) "")
    (setvar 'cmdecho 1)
    (mapcar '(lambda (sub_cabinet) (put_text sub_cabinet text_height h_factor line_spacing_factor)) cabinet) 
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 15:55:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295428#M3673</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2025-02-02T15:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295834#M3674</link>
      <description>&lt;P&gt;Give this a try, just open your Excel 1st, I tested on your csv file as Excel. This is version &lt;STRONG&gt;one&lt;/STRONG&gt; just to make it work. I did make one change I made a block for the cabinet details. See dwg. I will make it closer to what you provided. There is some checks to work out block CABLABEL always goes outside of shape.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if happy with progress and will do some more tidy ups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/td-p/13291071

; Read data from excel and make a pline and add blocks.
; BY AlanH FEB 2025

(defun c:mkcabs ( / cname colsmax label lst lst2 mp num oldsnap row rowsmax val x y)
(alert "Make sure you have correct Excel open\npress ESC if not ready and run again")

;;	Thanks to fixo			;;
(defun getcell2 (row column / )
  (setq cells (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Cells"))
  (setq cell (vlax-get (vlax-variant-value  (vlax-get-property cells "Item" row column)) 'value))
)

(defun LWPoly (plst cls)
  (entmakex (append (list (cons 0 "LWPOLYLINE")
  (cons 100 "AcDbEntity")
  (cons 100 "AcDbPolyline")
  (cons 90 (length plst))
  (cons 70 cls))
  (mapcar (function (lambda (p) (cons 10 p))) plst)))
)

(setq myxl1 (vlax-get-object "Excel.Application"))
(if (= myxl1 nil)
    (setq myxl (vlax-get-or-create-object "excel.Application"))
	(setq myxl myxl1)
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(setq colsmax (vlax-get (vlax-get (vlax-get-property (vlax-get-property  myxl "ActiveSheet") 'UsedRange) 'columns) 'count))
(setq rowsmax (vlax-get (vlax-get (vlax-get-property (vlax-get-property  myxl "ActiveSheet") 'UsedRange) 'rows) 'count))

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(setq row 1)

(repeat (/ rowsmax 4)
  (setq lst ' () lst2 '())
  (repeat 4
    (setq num (rtos (getcell2 row 1) 2 0))
    (setq X (getcell2 row 2))
    (setq y (getcell2 row 3))
    (setq label (getcell2 row 4))
    (setq cname (getcell2 row 5))
    (setq lst (cons (list num label cname) lst))
    (setq lst2 (cons (list x y) lst2))
    (setq row (1+ row))
  )
  (lwpoly lst2 1)
  (command "LINE" (nth 0 lst2) (nth 2 lst2) "")
  (command "LINE" (nth 1 lst2) (nth 3 lst2) "")
  (setq mp (inters (nth 0 lst2) (nth 2 lst2)(nth 1 lst2) (nth 3 lst2)))
  (command "-insert" "Cabinet" "s" 1.0 mp 0.0)
  (setq k 0)
  (foreach pt lst2
   (setq val (nth k lst))
   (command "-insert" "CABLABEL" pt 1 1 0.0 (car val) (cadr val) (caddr val))
   (setq k (1+ k))
  )
)

(setvar 'osmode oldsnap)

(if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil)))

(princ)
)
(c:mkcabs)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 00:28:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13295834#M3674</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-02-03T00:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296041#M3675</link>
      <description>&lt;P&gt;Thank so much&amp;nbsp; Kent,&lt;/P&gt;&lt;P&gt;Your lisp give me exactly what I need, that's great!!&lt;/P&gt;&lt;P&gt;About the color, I can explain here: the final final drawing we keep in file will only the blocks. However, when our check review our drawing, she want to see the point information, (those text in different color) and those construction lines (four lines around and two diagonal lines) to make sure no any mistake, so red, yellow, green color will be standout and easy for checker to see it, because my real working drawing is basemap drawing which contains over hundred layers and huge number of objects, and all layer color is 8. After our checker reviewed the drawing, she will delete all the text and turn off the red color construction lines.&lt;/P&gt;&lt;P&gt;I think if use your lisp, every point, lines, blocks will be on the accurate location without mistake form manually input, I will talk with my check see if she think still need check using the text and construction lines.&lt;/P&gt;&lt;P&gt;Thanks a lot again for your help! I really want to learn how to make the lisp by myself.&lt;/P&gt;&lt;P&gt;Bin&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 04:52:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296041#M3675</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-03T04:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296042#M3676</link>
      <description>&lt;P&gt;Hello komondormrex,&lt;/P&gt;&lt;P&gt;Thank so much&amp;nbsp; for your lisp, it also work perfect!&lt;/P&gt;&lt;P&gt;Highly appreciate for your help!&lt;/P&gt;&lt;P&gt;Bin&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 04:55:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296042#M3676</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-03T04:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a block at the intersection of two lines which come from 4 points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296061#M3677</link>
      <description>&lt;P&gt;Hello Sea-Haven,&lt;/P&gt;&lt;P&gt;Thank so much for your lisp, it also works perfect for me!&lt;/P&gt;&lt;P&gt;Highly appreciate for all your help!&lt;/P&gt;&lt;P&gt;Bin&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 05:18:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-a-block-at-the-intersection-of-two-lines-which-come-from/m-p/13296061#M3677</guid>
      <dc:creator>Bin2009</dc:creator>
      <dc:date>2025-02-03T05:18:54Z</dc:date>
    </item>
  </channel>
</rss>

