Как объединить _DIVIDE и _BREAK AT POINT - Страница 2
| Правила | Регистрация | Пользователи | Сообщения за день |  Справка по форуму | Файлообменник |

Вернуться   Форум DWG.RU > Программное обеспечение > Программирование > LISP > Как объединить _DIVIDE и _BREAK AT POINT

Как объединить _DIVIDE и _BREAK AT POINT

Ответ
Поиск в этой теме
Непрочитано 31.05.2024, 21:03
Как объединить _DIVIDE и _BREAK AT POINT
Ingpro
 
Регистрация: 11.07.2022
Сообщений: 756

Я пытаюсь объединить две команды, чтобы поделить объект и разбить по точкам
Код:
[Выделить все]
  (defun c:div-br-point ( )
 (setvar 'osmode 191) 
 (command "_DIVIDE")
 (prompt "\nЧисло сегментов: ")
 (command "_break")

 (setvar 'osmode 183)
  (princ)
)
Код выполняет команду _DIVIDE, но пишет в ком. строке:
Команда: DIV-BR-POINT
Число сегментов:
*Неверный выбор*
Требуется один объект.
; ошибка: Функция отменена
Выберите объект для деления:
Число сегментов или [Блок]: 3

на команду _break нет реакции...

Возможно ли в лисп установить PTYPE Х в абс.ед. 50

Миниатюры
Нажмите на изображение для увеличения
Название: Image 3.png
Просмотров: 32
Размер:	18.8 Кб
ID:	263278  Нажмите на изображение для увеличения
Название: Image 4.png
Просмотров: 29
Размер:	26.6 Кб
ID:	263279  


Последний раз редактировалось Ingpro, 02.06.2024 в 14:33.
Просмотров: 2211
 
Непрочитано 03.06.2024, 12:56
#21
name02


 
Регистрация: 10.01.2020
Сообщений: 415


https://forums.autodesk.com/t5/visua...761302#M404803
name02 вне форума  
 
Автор темы   Непрочитано 03.06.2024, 13:59
#22
Ingpro


 
Регистрация: 11.07.2022
Сообщений: 756


Цитата:
Сообщение от name02 Посмотреть сообщение
ttps://forums.autodesk.com/t5/visua...761302#M404803
Близко к моей задаче, но, предположим, я не знаю на какие части по длине мне надо разбить полилинию, но знаю на сколько частей (команда DIVIDE).
Я вызываю команду (назовем div-br-pt), сначала включается команда "поделить", выбираю объект, указываю сколько частей, дальше вопрос:
"Разделить по этим точкам?" - enter. Как-то так...
Ingpro вне форума  
 
Непрочитано 03.06.2024, 15:00
#23
name02


 
Регистрация: 10.01.2020
Сообщений: 415


Пришлось немного переделать под твою задачу
Оригинальный код - https://lee-mac.com/segmentcurve.html
Код:
[Выделить все]
 ;;-------------------------=={ Segment Curve }==------------------------;;
;;                                                                      ;;
;;  This program enables the user convert every object in a selection   ;;
;;  into a polyline approximating the object using a given number of    ;;
;;  linear segments.                                                    ;;
;;                                                                      ;;
;;  Upon calling the program with 'segs' at the AutoCAD command-line,   ;;
;;  the user is prompted to make a selection of planar curve objects    ;;
;;  (Arcs, Circles, Ellipses, Lines, Splines, or 2D Polylines) and      ;;
;;  then to specify the number of segments for the resulting polyline.  ;;
;;                                                                      ;;
;;  The program will then proceed to create a 2D polyline with          ;;
;;  properties identical to each selected object, approximating the     ;;
;;  selected object using the specified number of linear segments.      ;;
;;                                                                      ;;
;;  If a selected object has a coordinate with non-zero Z-component,    ;;
;;  the resultant polyline will have an elevation equal to the          ;;
;;  Z-component of the first point on the curve.                        ;;
;;----------------------------------------------------------------------;;
;;  Author:  Lee Mac, Copyright © 2011  -  www.lee-mac.com              ;;
;;----------------------------------------------------------------------;;
;;  Version 1.0    -    2011-04-18                                      ;;
;;                                                                      ;;
;;  - First release.                                                    ;;
;;----------------------------------------------------------------------;;
;;  Version 1.1    -    2016-04-24                                      ;;
;;                                                                      ;;
;;  - Program entirely rewritten.                                       ;;
;;----------------------------------------------------------------------;;

(defun c:segs (/ *error* dis ent idx inc lst num pnt sel tmp DistList breakPt count)

  (defun *error* (msg)
    (LM:endundo (LM:acdoc))
    (if	(not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
      (princ (strcat "\nError: " msg))
    ) ;_ end of if
    (princ)
  ) ;_ end of defun

  (if
    (not
      (and
	(setq num (getenv "LMac\\segs"))
	(setq num (atoi num))
	(< 0 num)
      ) ;_ end of and
    ) ;_ end of not
     (setenv "LMac\\segs" (itoa (setq num 10)))
  ) ;_ end of if
  (if (setq sel
	     (ssget "_:L+.:S"
		    '(
		      (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")
		      (-4 . "<NOT")
		      (-4 . "<AND")
		      (0 . "POLYLINE")
		      (-4 . "&")
		      (70 . 88)
		      (-4 . "AND>")
		      (-4 . "NOT>")
		     )
	     ) ;_ end of ssget
      ) ;_ end of setq
    (progn
      (initget 6)
      (if (setq	tmp (getint
		      (strcat "\nSpecify number of segments <" (itoa num) ">: ")
		    ) ;_ end of getint
	  ) ;_ end of setq
	(setenv "LMac\\segs" (itoa (setq num tmp)))
      ) ;_ end of if
      (LM:startundo (LM:acdoc))
      (repeat (setq idx (sslength sel))
	(setq ent (ssname sel (setq idx (1- idx)))
	      inc (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))
		     (float num)
		  ) ;_ end of /
	      dis 0.0
	      lst nil
	) ;_ end of setq
	(repeat	(1+ num)
	  (if (setq pnt (vlax-curve-getpointatdist ent dis))
	    (setq lst (cons (cons 10 (trans pnt 0 ent)) lst))
	  ) ;_ end of if
	  (setq dis (+ dis inc))
	) ;_ end of repeat
	(if (not (equal	(vlax-curve-getendpoint ent)
			(trans (cdar lst) ent 0)
			1e-6
		 ) ;_ end of equal
	    ) ;_ end of not
	  (setq	lst (cons (cons 10 (trans (vlax-curve-getendpoint ent) 0 ent))
			  lst
		    ) ;_ end of cons
	  ) ;_ end of setq
	) ;_ end of if

	;; sort the points so we won't try to break the NEW pline that is created after a successful break
	(setq count 0)
	(repeat	(length lst)
	  (setq	DistList (append DistList
				 (list
				   (vlax-curve-GetDistAtPoint
				     (ssname sel 0)
				     (vlax-curve-getClosestPointTo (ssname sel 0) (cdr (nth count lst)))
				   ) ;_ end of vlax-curve-GetDistAtPoint
				 ) ;_ end of list
			 ) ;_ end of append
	  ) ;_ end of setq
	  (setq count (+ 1 count))
	) ;_ end of repeat



	(mapcar	'(lambda (x)
		   (setq breakPt (cdr (nth x lst)))
		   (command "_break" (ssname sel 0) breakPt "@")
		 ) ;_ end of lambda
		(vl-sort-i DistList '>)
	) ;_ end of mapcar



      ) ;_ end of repeat
      (LM:endundo (LM:acdoc))
    ) ;_ end of progn
  ) ;_ end of if
  (princ)
) ;_ end of defun

;; Default Properties  -  Lee Mac
;; Returns a list of DXF properties for the supplied DXF data,
;; substituting default values for absent DXF groups

(defun LM:defaultprops (enx)
  (mapcar '(lambda (x)
	     (cond ((assoc (car x) enx))
		   (x)
	     ) ;_ end of cond
	   ) ;_ end of lambda
	  '(
	    (006 . "BYLAYER")
	    (008 . "0")
	    (039 . 0.0)
	    (048 . 1.0)
	    (062 . 256)
	    (370 . -1)
	   )
  ) ;_ end of mapcar
) ;_ end of defun

;; Start Undo  -  Lee Mac
;; Opens an Undo Group.

(defun LM:startundo (doc)
  (LM:endundo doc)
  (vla-startundomark doc)
) ;_ end of defun

;; End Undo  -  Lee Mac
;; Closes an Undo Group.

(defun LM:endundo (doc)
  (while (= 8 (logand 8 (getvar 'undoctl)))
    (vla-endundomark doc)
  ) ;_ end of while
) ;_ end of defun

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc	nil
  (eval	(list 'defun
	      'LM:acdoc
	      'nil
	      (vla-get-activedocument (vlax-get-acad-object))
	) ;_ end of list
  ) ;_ end of eval
  (LM:acdoc)
) ;_ end of defun

;;----------------------------------------------------------------------;;

(vl-load-com)
(princ
  (strcat
    "\n:: SegmentCurve.lsp | Version 1.1 | \\U+00A9 Lee Mac "
    (menucmd "m=$(edtime,0,yyyy)")
    " www.lee-mac.com ::"
    "\n:: Type \"segs\" to Invoke ::"
  ) ;_ end of strcat
) ;_ end of princ
(princ)

;;----------------------------------------------------------------------;;
;;                             End of File                              ;;
;;----------------------------------------------------------------------;;
name02 вне форума  
 
Автор темы   Непрочитано 03.06.2024, 15:31
#24
Ingpro


 
Регистрация: 11.07.2022
Сообщений: 756


Цитата:
Сообщение от name02 Посмотреть сообщение
Пришлось немного переделать под твою задачу
Оригинальный код - https://lee-mac.com/segmentcurve.html
Спасибо, name02, но не делит?...
Команда: SEGS
Выберите объекты:
Specify number of segments <5>:
VVC: Internal Error
Это в AutoCAD 2015. Проверяю в 2020 - работает!! И с полилиниями и с дугами.
Заменяю command на command-s и всё работает и в AutoCAD 2015. Это VVC: Internal Error
Спасибо большое!

Последний раз редактировалось Ingpro, 04.06.2024 в 09:50.
Ingpro вне форума  
 
Непрочитано 03.06.2024, 15:49
#25
name02


 
Регистрация: 10.01.2020
Сообщений: 415


Специально скачал с форума выложенный мною код и запустил во вновь открытом документе - все работает
name02 вне форума  
 
Автор темы   Непрочитано 03.06.2024, 15:59
#26
Ingpro


 
Регистрация: 11.07.2022
Сообщений: 756


Цитата:
Сообщение от name02 Посмотреть сообщение
Специально скачал с форума выложенный мною код и запустил во вновь открытом документе - все работает
Это замена command на command-s и версии AutoCAD.
В 2015 работает с command-s, в 2020 с command и с command-s...

Последний раз редактировалось Ingpro, 04.06.2024 в 09:51.
Ingpro вне форума  
Ответ
Вернуться   Форум DWG.RU > Программное обеспечение > Программирование > LISP > Как объединить _DIVIDE и _BREAK AT POINT



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Не получается объединить все грани сети, находящиеся на одной плоскости lloydst AutoCAD 0 09.04.2021 16:54
Point Name, 3D offset и др. в Autodesk Land Desktop 2007 Re-Maker Вертикальные решения на базе AutoCAD 2 12.08.2014 10:19
C#.NET. Переопределение ручек (Grip Overrule). Do$ .NET 7 20.05.2013 15:22
AutoCAD2010 выдает 82 отчета об ошибке за раз Nusia AutoCAD 22 29.08.2012 16:11
Regen Holon Программирование 28 03.08.2007 15:18