ribarm 发表于 2018-10-28 11:53:40

重新创建路径曲线。。。

我想在这个网站上也讨论这个问题:
https://www.cadtutor.net/forum/topic/66077-recreat-path-of-object-array-path/
除了阵列路径对象之外,还必须考虑扫掠或路径拉伸三维实体…
我开始觉得这是在地毯下…
。。。
**** Hidden Message *****

ribarm 发表于 2018-10-28 20:20:17

我想出了数组路径匿名块...
(defun c:extractarraypathcurve ( / refgeom mxv mxm trp arraypth n on ospc met e ip p pl )

;; RefGeom (gile)
;; Returns a list whose first item is a 3x3 transformation matrix and
;; second item the object insertion point in its parent (xref, block or space)
   
(defun refgeom ( ent / ang enx mat ocs )
      (setq enx (entget ent)
            ang (cdr (assoc 050 enx))
            ocs (cdr (assoc 210 enx))
      )
      (list
          (setq mat
            (mxm
                  (mapcar '(lambda ( v ) (trans v 0 ocs t))
                     '(
                        (1.0 0.0 0.0)
                        (0.0 1.0 0.0)
                        (0.0 0.0 1.0)
                      )
                  )
                  (mxm
                      (list
                        (list (cos ang) (- (sin ang)) 0.0)
                        (list (sin ang) (cos ang)   0.0)
                         '(0.0 0.0 1.0)
                      )
                      (list
                        (list (cdr (assoc 41 enx)) 0.0 0.0)
                        (list 0.0 (cdr (assoc 42 enx)) 0.0)
                        (list 0.0 0.0 (cdr (assoc 43 enx)))
                      )
                  )
            )
          )
          (mapcar '- (trans (cdr (assoc 10 enx)) ocs 0)
            (mxv mat (cdr (assoc 10 (tblsearch "block" (cdr (assoc 2 enx))))))
          )
      )
)

;; Matrix x Vector-Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
   
(defun mxv ( m v )
      (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)
   
;; Matrix x Matrix-Vladimir Nesterovsky
;; Args: m,n - nxn matrices
   
(defun mxm ( m n )
      ((lambda ( a ) (mapcar '(lambda ( r ) (mxv a r)) m)) (trp n))
)
   
;; Matrix Transpose-Doug Wilson
;; Args: m - nxn matrix
   
(defun trp ( m )
      (apply 'mapcar (cons 'list m))
)

(while
    (or
      (not (setq arraypth (car (entsel "\nPick ARRAYPATH BLOCK..."))))
      (if arraypth
      (or
          (/= (cdr (assoc 0 (entget arraypth))) "INSERT")
          (not (wcmatch (cdr (assoc 2 (entget arraypth))) "`*U*"))
      )
      )
    )
    (prompt "\nMissed or picked wrong entity type...")
)
(initget 6)
(setq n (getint "\nSpecify density of array - precision of curve recreation: "))
(if (null n)
    (setq n 25)
)
(setq on (getpropertyvalue arraypth "Items"))
(setq ospc (getpropertyvalue arraypth "ItemSpacing"))
(setq met (getpropertyvalue arraypth "Method"))
(vl-cmdf "_.ARRAYEDIT" arraypth "_M" "_D" "_I" n)
(while (
    (vl-cmdf "")
)
(setq e (tblobjname "BLOCK" (cdr (assoc 2 (entget arraypth)))))
(while (setq e (entnext e))
    (setq ip (cadr (refgeom e)))
    (setq p (apply '(lambda ( mat vec ) (mapcar '+ (mxv mat ip) vec)) (refgeom arraypth)))
    (setq pl (cons p pl))
)
(setq pl (reverse pl))
(vl-cmdf "_.SPLINE")
(foreach p pl
    (vl-cmdf "_non" (trans p 0 1))
)
(while (
    (vl-cmdf "")
)
(if (= met 0)
    (vl-cmdf "_.ARRAYEDIT" arraypth "_M" "_D" "_I" on)
    (vl-cmdf "_.ARRAYEDIT" arraypth "_M" "_M" "_I" on ospc)
)
(while (
    (vl-cmdf "")
)
(princ)
)

3D SOLIDS 仍然保留 - 通过路径和扫描进行挤压...我不知道如何获得表示横截面的区域的质心...我基本上不知道如何生成横截面...
问候, M.R.

Roy_043 发表于 2018-10-29 04:04:33

我认为不可能准确地重现路径阵列的路径。例如,如果原始路径在阵列项目之间包含一个小之字形。

Bryco 发表于 2018-10-29 17:32:54

我用曲线来求管子的路径。但当然,这有一个非常有限的用途

ribarm 发表于 2018-10-30 07:21:54


抱歉,曲面的surfv等值线并不完全遵循主中心路径曲率…
顺便说一句。我用扫地的方法做到了这一点,但这很复杂,需要人工干预;通过NETLOAD使用DLL;一些短的LSP文件,它以我在上面发布的例程中使用的方式重新创建形状…基本上,我得到闭合的三维多段线截面,然后将其转换为区域,并将其仅拉伸1e-3,以从参考拉伸中获得WCS中的质心,然后将起点/终点添加到质心的点列表中-扫描是打开的,因此没有起点/终点三维多段线横截面-必须手动创建它们,并获得附加到点列表的质心,最后是样条线命令-通过所有点…我已经检查过,我可以清楚地说,只有这种方式才有一定的正确性-沿与横截面相反的方向复制提取的曲线将其放置在扫描路径的开始位置是错误的。。。

ribarm 发表于 2018-10-30 10:09:52

然而,罗伊有道理...我认为重新创建路径的准确性很重要...所以我的方法很糟糕,但话又说回来,我不知道该怎么做 - 直接从复杂对象中提取精确的曲线......似乎来自曲线的主要数据存储在复杂对象内部的某个地方......因此,如果其他人有不同的东西,请告诉我们,如果这不是机密的......

ribarm 发表于 2018-10-30 18:50:50

嗨,我知道了如何获得精确的扫掠和路径拉伸路径…首先,主形状不能是圆-你必须将其转换为lwpolyline-还必须将椭圆转换为pellipse(lwpolyline)-也可以将样条线转换为LW Polyline-具有密集的直线段…然后你将这些形状的扫掠或按路径拉伸到任何曲线路径…生成3DSOLID时,移除路径曲线,然后进行实验…沿X或Y方向将3DSOLID复制一些单位,然后缩放到实验3DSOLID…然后单击3DSOLID,将显示夹点-路径质心中有来自形状基础的夹点和夹点,这是虚构的-但夹点存在…然后单击形状中的一个夹点,直到与路径夹点重叠,就是这样…现在只需执行此操作SOLIDEDIT->边->复制边,然后单击沿路径的所有边-3DSOLID的一个包络边必须与路径曲线重叠…将所有接触的路径边复制到新位置的X和Y方向,然后缩放到位置-最后应用连接命令,即路径已重新创建…现在将路径复制回-将X和Y方向反转2倍距离,它应该是起始路径曲线的精确副本…因此只需将圆转换为lwpolyline:
(defun c:ci2lw ( / ss i ent dxf_ent pt_cen radius fst_pt opp_pt new_ep )
(princ "\nSelect a circles to be converted into a donuts - LWPOLYLINES...")
(while (null (setq ss (ssget "_:L" '((0 . "CIRCLE")))))
    (princ "\nEmpty sel.set... Try again...")
)
(princ "\nThickness of donut
(princ (getvar "PLINEWID"))
(princ ">: ")
(initget 68)
(setq new_ep (getdist))
(if new_ep (setvar "PLINEWID" new_ep))
(repeat (setq i (sslength ss))
    (setq
      ent (ssname ss (setq i (1- i)))
      dxf_ent (entget ent)
      pt_cen (cdr (assoc 10 dxf_ent))
      radius (cdr (assoc 40 dxf_ent))
      fst_pt (polar pt_cen 0.0 radius)
      opp_pt (polar pt_cen pi radius)
    )
    (entmake
      (vl-remove nil
      (list
          '(0 . "LWPOLYLINE")
          '(100 . "AcDbEntity")
          (assoc 67 dxf_ent)
          (assoc 410 dxf_ent)
          (assoc 8 dxf_ent)
          (if (assoc 6 dxf_ent) (assoc 6 dxf_ent) '(6 . "BYLAYER"))
          (if (assoc 62 dxf_ent) (assoc 62 dxf_ent) '(62 . 256))
          (if (assoc 420 dxf_ent) (assoc 420 dxf_ent))
          (if (assoc 370 dxf_ent) (assoc 370 dxf_ent) '(370 . -3))
          (if (assoc 48 dxf_ent) (assoc 48 dxf_ent) '(48 . 1.0))
          '(100 . "AcDbPolyline")
          '(90 . 2)
          '(70 . 1)
          (cons 43 (getvar "PLINEWID"))
          (cons 38 (caddr pt_cen))
          (if (assoc 39 dxf_ent) (assoc 39 dxf_ent) '(39 . 0.0))
          (cons 10 (list (car fst_pt) (cadr fst_pt)))
          '(40 . 0.0)
          '(41 . 0.0)
          '(42 . 1.0)
          (cons 10 (list (car opp_pt) (cadr opp_pt)))
          '(40 . 0.0)
          '(41 . 0.0)
          '(42 . 1.0)
          (assoc 210 dxf_ent)
      )
      )
    )
    (entdel ent)
)
(princ)
)

(defun c:lwc ( / cmd ent dxf_ent pt_cen radius fst_pt opp_pt new_ep )
(setq cmd (getvar 'cmdecho))
(setvar 'cmdecho 1)
(vl-cmdf "_.CIRCLE")
(while (> (getvar 'cmdactive) 0) (vl-cmdf "\\"))
(setq
    ent (entlast)
    dxf_ent (entget ent)
    pt_cen (cdr (assoc 10 dxf_ent))
    radius (cdr (assoc 40 dxf_ent))
    fst_pt (polar pt_cen 0.0 radius)
    opp_pt (polar pt_cen pi radius)
)
(entmake
    (vl-remove nil
      (list
      '(0 . "LWPOLYLINE")
      '(100 . "AcDbEntity")
      (assoc 67 dxf_ent)
      (assoc 410 dxf_ent)
      (assoc 8 dxf_ent)
      (if (assoc 6 dxf_ent) (assoc 6 dxf_ent) '(6 . "BYLAYER"))
      (if (assoc 62 dxf_ent) (assoc 62 dxf_ent) '(62 . 256))
      (if (assoc 420 dxf_ent) (assoc 420 dxf_ent))
      (if (assoc 370 dxf_ent) (assoc 370 dxf_ent) '(370 . -3))
      (if (assoc 48 dxf_ent) (assoc 48 dxf_ent) '(48 . 1.0))
      '(100 . "AcDbPolyline")
      '(90 . 2)
      '(70 . 1)
      (cons 43 (getvar "PLINEWID"))
      (cons 38 (caddr pt_cen))
      (if (assoc 39 dxf_ent) (assoc 39 dxf_ent) '(39 . 0.0))
      (cons 10 (list (car fst_pt) (cadr fst_pt)))
      '(40 . 0.0)
      '(41 . 0.0)
      '(42 . 1.0)
      (cons 10 (list (car opp_pt) (cadr opp_pt)))
      '(40 . 0.0)
      '(41 . 0.0)
      '(42 . 1.0)
      (assoc 210 dxf_ent)
      )
    )
)
(entdel ent)
(setvar 'cmdecho cmd)
(princ)
)

对于椭圆-使用PELLIPSE sys var,当设置为1时,使用ELLIPSE命令创建Pelipse…
现在,当您有多边形扫掠和路径拉伸时,您不需要路径-您可以重新创建它并使用它修改现有3DSOLID,或使用相同的路径参考指南创建类似的3DSOLID…或阵列路径,或者,…任何您想要的…
请记住,为了将来-不要使用圆或椭圆-基本实体需要可拉伸形状。。。

Bryco 发表于 2018-10-31 19:44:15

当然,SURFEXTRACTCURVE确实需要您找到2条曲线之间的中位数。
页: [1]
查看完整版本: 重新创建路径曲线。。。