偏移三维多段线
你好在OFFSET命令的“帮助”部分中,未将三维多段线指定为可以偏移的对象。
如何在多段线所在的平面中偏移三维多段线,有什么提示吗?
非常感谢。 正如你所说,它不能偏移,作为一条三维多段线,
但如果分解它或其副本,则生成的线可能会偏移。
如果需要,您可以在偏移线上进行追踪,以创建三维多段线
你大概更喜欢哪一种。
这并不完美,但作为一种解决方法,我希望它能帮助你。 试试这个:
; Offset a 3dPoly with horizontal and vertical distances
; 15 August 2014 - Gian Paolo Cattaneo
(defun c:o3 ( / *error* 3dp p ogt)
(defun *error* ( msg )
(setvar 'offsetgaptype ogt)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(setq ogt (getvar 'offsetgaptype))
(setvar 'offsetgaptype 0)
(or op (setq op 0.00))
(or oz (setq oz 0.00))
(while
(progn
(setq 3dp (car (entsel "\nSelect the 3D polyline to offset")))
(if (not (eq "AcDb3dPolyline" (vlax-get (vlax-ename->vla-object 3dp) 'ObjectName)))
(progn
(alert "This is not a 3D Polyline")
t
)
)
)
)
(if 3dp
(progn
(while
(progn
(initget (+ 2 4))
(setq op
(cond
( (getdist (strcat "\nOffset Distance (horizontal)<" (rtos op 2 2)">: ")) )
( op )
)
)
(if (= op 0.)
(progn
(alert "The horizontal offset distance must be greater than zero")
t
)
)
)
)
(setq oz
(cond
( (getdist (strcat "\nOffset Distance (vertical) <" (rtos oz 2 2)">: ")) )
( oz )
)
)
(setq p (getpoint "\nSpecify point on side to offset "))
(off3DP 3dp op oz p)
)
)
(setvar 'offsetgaptype ogt)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ)
)
;******************* Offset 3D Polyline ********************;
; ;
;obj - entity name ;
;d_o - horizontal offset distance ;
;d_z - vertical offset distance ;
;p_of
- point on side to offset ;
; ;
; ----------------------------------------------------------;
; (off3DP (car (entsel)) 2.15 -2.00 '(3 4 0)) ;
; ----------------------------------------------------------;
; author: Gian Paolo Cattaneo - 30.03.2013 ;
;***********************************************************;
(defun off3DP ( obj d_o d_z p_of / EL Lv PL2 PL3 Lv Lv1 Lv2 n_of obj_of)
(if
(and
(eq "AcDb3dPolyline" (vlax-get (vlax-ename->vla-object obj) 'ObjectName))
(setq Lv (pl_coord obj))
(setq PL2
(entmakex
(append
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 (length Lv))
(cons 70 (if (vlax-curve-IsClosed obj) 1 0))
(cons 43 0.0)
)
(mapcar '(lambda (x) (cons 10 x)) Lv)
)
)
)
)
(progn
(setq EL (entlast))
(vl-cmdf "_offset" d_o PL2 p_of "")
(if (and
(/= EL (setq PL3 (entlast)))
(= (setq n_of (length (setq obj_of (e_next EL "LS")))) 1)
)
(progn
(setq Lv2 nil)
(setq Lv1 (pl_coord PL3))
(entdel PL2)
(entdel PL3)
(mapcar
'(lambda ( a b )
(setq Lv2 (cons (list (car b) (cadr b) (+ d_z (caddr a))) Lv2))
)
Lv Lv1
)
(setq Lv2 (reverse Lv2))
(entmake
(list
'(0 . "POLYLINE")
'(10 0.0 0.0 0.0)
(assoc 8 (entget obj))
(assoc 70 (entget obj))
)
)
(repeat (length Lv2)
(entmake
(list
(cons 0 "VERTEX")
(cons 10 (CAR Lv2))
(cons 70 32)
)
)
(setq Lv2 (cdr Lv2))
)
(entmake '((0 . "SEQEND")))
t
)
(progn
(entdel PL2)
(if (> n_of 1)
(repeat n_of
(entdel (car obj_of))
(setq obj_of (cdr obj_of))
)
)
nil
)
)
)
)
)
;***********************************************************;
(defun pl_coord (# / p m)
(setq p (if (vlax-curve-IsClosed #)
(fix (vlax-curve-getEndParam #))
(1+ (fix (vlax-curve-getEndParam #)))
)
)
(while (/= 0 p)
(setq m (cons (vlax-curve-getPointAtParam # (setq p (1- p))) m))
)
)
;***********************************************************;
(defun e_next (entL mode / next)
(if (= mode "SS") (setq next (ssadd)))
(if (/= entL (entlast))
(while (setq entL (entnext entL))
(if (entget entL)
(cond
( (= mode "LS") (setq next (cons entL next)) )
( (= mode "SS") (setq next (ssadd entL next)) )
)
)
)
)
next
)
(vl-load-com)
;***********************************************************;
(prompt "\n ") (prompt "\n ")
(princ "\n\\U+00ABOffset 3D Polyline - Type \"o3\" to run\\U+00BB")
(princ)
可以使用OFFSETFEATURE命令在Civil 3D和MAP中偏移三维多段线,但我不知道Mechanical中是否存在该命令。 谢谢各位!
GP_我是AutoCAD的初学者,我不知道如何使用你的代码。首先,我必须阅读帮助,看看该怎么办。这是Lisp程序吗?我需要搜索关键字。 是的,赫奇科,那是Lisp程序。看看李的网站,在那里他有一些伟大的信息开始与Lisp程序。这是www.lee-mac的链接。通用域名格式 这是我的旧的,但我找到了。。。试试看,也许它能帮你解决问题。。。
(defun c:3doffset-3dpoly ( / ent entA entcoordlst pt3d pt2d entvertlst3d entvertlst2d pto d 2dplo 2dpln 2dplncoordlst 2dplnvertlst3d ptx pty ptz ptxlst ptylst ptzlst 3dplnvertlst3d )
(setq oscmd (getvar 'osmode))
(setvar 'osmode 0)
(setq ent (car (entsel "\nSelect 3D Polyline - 3dpline must not have vertical segments")))
(vl-load-com)
(setq entA (vlax-ename->vla-object ent))
(setq entcoordlst (vlax-safearray->list (vlax-variant-value (vla-get-Coordinates entA))))
(repeat (/ (length entcoordlst) 3)
(setq pt3d (list (car entcoordlst) (cadr entcoordlst) (caddr entcoordlst)))
(setq pt2d (list (car entcoordlst) (cadr entcoordlst) 0 ))
(repeat 3
(setq entcoordlst (cdr entcoordlst))
)
(setq entvertlst3d (cons pt3d entvertlst3d))
(setq entvertlst2d (cons pt2d entvertlst2d))
)
(setq entvertlst3d (reverse entvertlst3d))
(setq entvertlst2d (reverse entvertlst2d))
(command "pline")
(foreach pt entvertlst2d (command pt))
(command "")
(command "ucs" "w")
(command "plan" "")
(setq pto (getpoint "\nPick point for side for 3doffset (in/out) : "))
(setq pto (list (car pto) (cadr pto) 0))
(setq d (getdist "\nInput horizontal distance for 3doffset (2 points) : "))
(setq 2dplo (entlast))
(command "offset" d (entlast) pto "")
(entdel 2dplo)
(setq 2dpln (entlast))
(setq 2dplnA (vlax-ename->vla-object 2dpln))
(setq 2dplncoordlst (vlax-safearray->list (vlax-variant-value (vla-get-Coordinates 2dplnA))))
(repeat (/ (length 2dplncoordlst) 2)
(setq pt3d (list (car 2dplncoordlst) (cadr 2dplncoordlst) 0 ))
(repeat 2
(setq 2dplncoordlst (cdr 2dplncoordlst))
)
(setq 2dplnvertlst3d (cons pt3d 2dplnvertlst3d))
)
(setq 2dplnvertlst3d (reverse 2dplnvertlst3d))
(entdel 2dpln)
(repeat (length 2dplnvertlst3d)
(setq ptx (car (car 2dplnvertlst3d)))
(setq pty (cadr (car 2dplnvertlst3d)))
(setq 2dplnvertlst3d (cdr 2dplnvertlst3d))
(setq ptxlst (cons ptx ptxlst))
(setq ptylst (cons pty ptylst))
)
(setq ptxlst (reverse ptxlst))
(setq ptylst (reverse ptylst))
(repeat (length entvertlst3d)
(setq ptz (caddr (car entvertlst3d)))
(setq entvertlst3d (cdr entvertlst3d))
(setq ptzlst (cons ptz ptzlst))
)
(setq ptzlst (reverse ptzlst))
(repeat (length ptzlst)
(setq ptn (list (car ptxlst) (car ptylst) (car ptzlst)))
(setq ptxlst (cdr ptxlst))
(setq ptylst (cdr ptylst))
(setq ptzlst (cdr ptzlst))
(setq 3dplnvertlst3d (cons ptn 3dplnvertlst3d))
)
(setq 3dplnvertlst3d (reverse 3dplnvertlst3d))
(command "3dpoly")
(foreach pt 3dplnvertlst3d (command pt))
(command "")
(setvar 'osmode oscmd)
(princ)
)
将代码复制并粘贴到记事本后,选择“另存为”并键入3doffset-3dpoly。lsp。。。然后启动ACAD并键入appload并选择3doffset-3dpoly。lsp。。。加载lisp后,只需键入3doffset-3dpoly即可启动它。。。或者,您不必使用appload命令,但单击lisp并按ctrl+c(复制),然后转到CAD绘图界面并按ctrl+v(粘贴)=>将加载lisp-在那里您可以看到上次加载的(defun函数(args/vars))-您将看到c:3dpoffset-3dpoly,这意味着命令函数3dpoffset-3dpoly已加载。。。然后键入3doffset-3dpoly以启动并遵循例程在执行过程中要求的过程。。。我希望我解释得很好。。。同样的程序可以应用于GP的代码。。。唯一不同的是,您必须用test启动它,在将lisp复制并粘贴到CAD界面的过程中,您将看到上次加载的defun(e_next)函数,但事实上,之前编写的所有defun都是同时加载的,因此您可以用test-first(defun c:test(/vars))启动它。。。当然,然后遵循正在执行的工作例程所要求的提示。。。
HTH,M.R。 Marko,感谢您提供有关加载LISP代码的详细说明。我会试试的。
Tyke为我提供了LISP的有用链接。 也许,ako nesto nije jasno ti slobodno pitaj。。。
Inace,moja rutina je predvidjena za otvorene 3d polilinije,ali radi i sa zatvorenim。。。伊奈采三维polilinije u sustini nije moguce-3d of set bi bio nesto kao kopiranje za neki vektor。。。U mom slucaju 3d polilinija se proicira na WCS ravan,pa se ofsetuje 2d polilinija,pa se vrate sve KOORDENTE novoj 3d poliliniji ali sa z KOORDENTIAM preuzetom od originalne 3d polilinije-SOFTOVANJE的水平编号。。。Ovo mi je ranije trebalo za kalkulaciju preseka terena i 3d objekta cije su ivice ustvari 3d POLINIJA-na taj nacin moze se odrediti usek i nasip zemljanih radova-samo treba znati koristiti loft komandu i solid operacije:SUTRAKCIJA,INTERKCIJA,unija。。。 Marko,我试过你的代码,但最后出错了,因为没有定义名称坐标。(ActiveX服务器返回错误:未知名称:坐标)
GP_,您的代码运行时没有错误,但我无法获得偏移ed多段线。
谢谢你的好意和帮助。我必须学习更多关于LISP编程的知识。
页:
[1]
2