Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/09/2023 in all areas

  1. This will be enough and should work, but not tested... (defun c:get_pline_data (/ pline_ent division_distance road_start_x road_end_x cur_x point ) ;;; res_y - global variable (setq pline_ent (car (entsel "\nSelect pline"))) (setq division_distance 50) ; should be 1 unit but for this example it is set to 50 (setq road_start_x (car (setq point (vlax-curve-getstartpoint pline_ent)))) (setq road_end_x (car (vlax-curve-getendpoint pline_ent))) (setq cur_x road_start_x) (while (<= cur_x road_end_x) (setq point (vlax-curve-getclosestpointtoprojection pline_ent point (list 0.0 1.0 0.0))) (setq res_y (cons (cadr point) res_y)) (setq cur_x (+ cur_x division_distance)) (setq point (mapcar '+ (list division_distance 0.0 0.0) point)) ) (princ) ) HTH. M.R.
    1 point
  2. Maybe use ssad instead of the cons after making the point, (ssadd (entlast) mypoints) then (comand "erase" mypoints "") no need for a foreach. Good idea display a point, may need a pdmode and pdsize as I got a dot using the entmake so maybe would not see the point. pdmode 34 ?
    1 point
  3. ; Find Last Row/Column in Excel - 2023.09.08 exceed ; command ; FLRE = find last row ; FLCE = find last column (defun c:FLRE () (ex:FLRCE "R") ) (defun c:FLCE () (ex:FLRCE "C") ) (defun ex:FLRCE ( rc / xlApp xlBook xlSheet AcSheet Cells xlcols xlrows Maxcols MaxRows ColumnInput RowInput ColumnInt addr Rng finddirection whatyoufind whatyoufindrow whatyoufindcol whatyoufindtxt ) (vl-load-com) ;------------------------------------------------------------------------------- ; Number2Alpha - Converts Number into Alpha string ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Num# = Number to convert ; Syntax example: (Number2Alpha 731) = "ABC" ;------------------------------------------------------------------------------- (defun Number2Alpha (Num# / Val#) (if (< Num# 27) (chr (+ 64 Num#)) (if (= 0 (setq Val# (rem Num# 26))) (strcat (Number2Alpha (1- (/ Num# 26))) "Z") (strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#))) ) ) ) ; Alpha2Number - Converts Alpha string into Number ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Str$ = String to convert ; Syntax example: (Alpha2Number "ABC") = 731 ;------------------------------------------------------------------------------- (defun Alpha2Number (Str$ / Num#) (if (= 0 (setq Num# (strlen Str$))) 0 (+ (* (- (ascii (strcase (substr Str$ 1 1))) 64) (expt 26 (1- Num#))) (Alpha2Number (substr Str$ 2)) ) ) ) (setq xlApp (vlax-get-or-create-object "Excel.Application")) (setq xlBook (vlax-get-property xlApp 'Workbooks)) (setq xlSheet (vlax-get-property xlApp 'Sheets)) (setq AcSheet (vlax-get-property xlApp 'ActiveSheet)) (setq Cells (vlax-get-property AcSheet 'Cells)) (setq xlcols (vlax-get-property AcSheet 'Columns)) (setq xlrows (vlax-get-property AcSheet 'Rows)) (setq MaxCols (vlax-get-property xlcols 'Count)) (setq MaxRows (vlax-get-property xlrows 'Count)) (cond ((= rc "R") (setq ColumnInput (getstring "\n Enter the Column Number to find the last Row (A,B,C.. or 1,2,3..) : ")) (setq ColumnInt (atoi ColumnInput)) (if (and (= ColumnInt 0) (/= CoumnInput "0")) (progn (setq ColumnInput (strcase ColumnInput)) ) (progn (setq ColumnInput (Number2Alpha ColumnInt)) ) ) (setq addr (strcat ColumnInput (itoa MaxRows))) (setq finddirection 3) ) ((= rc "C") (setq RowInput (getint "\n Enter the Row Number to find the last Column (1,2,3..) : ")) (setq addr (strcat (Number2Alpha MaxCols) (itoa RowInput))) (setq finddirection 1) ) ) (setq Rng (vlax-get-property AcSheet 'Range addr)) (setq whatyoufind (vlax-get-property Rng 'End finddirection)) ; finddirection : 1 = xlToLeft, 2 = xlToRight, 3 = xlUp, 4 = xlDown (setq whatyoufindrow (vlax-get-property whatyoufind 'row)) (setq whatyoufindcol (vlax-get-property whatyoufind 'column)) (setq whatyoufindtxt (vlax-variant-value (vlax-get-property whatyoufind 'value))) (if (= whatyoufindtxt nil) (setq whatyoufindtxt "")) (vlax-invoke whatyoufind 'select) ;If you don't need to select a cell, delete this line (cond ((= rc "R") (princ "Last non-empty cell in column [ ") (princ ColumnInput) (princ " (= ") (princ (Alpha2Number ColumnInput)) (princ " ) ] is in row [ ") (princ whatyoufindrow) ) ((= rc "C") (princ "Last non-empty cell in Row [ ") (princ RowInput) (princ " ] is in column [ ") (princ (Number2Alpha whatyoufindcol)) (princ " (= ") (princ whatyoufindcol) (princ " )") ) ) (princ " ], with value : [ ") (princ whatyoufindtxt) (princ " ].") (vlax-release-object xlApp) (princ) ) command = FLRE then input column number by number or alphabet
    1 point
×
×
  • Create New...