Author Topic: XClipping  (Read 12408 times)

0 Members and 2 Guests are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
XClipping
« on: August 17, 2011, 12:39:31 PM »
Ok, I have tried searching, but have not found anything, does anyone have a routine that will find the XCLIP boundary for an XRef and apply it to another XRef?

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: XClipping
« Reply #1 on: August 17, 2011, 12:53:12 PM »
Just a "stab in the dark" ... run the XClip command with its Generate Polyline feature, then run it again with Select Polyline, the Erase the polyline.

Obviously there might be cleaner code than doing everything through the command line, but hell, it's quick & simple!
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: XClipping
« Reply #2 on: August 17, 2011, 01:19:30 PM »
Just a "stab in the dark" ... run the XClip command with its Generate Polyline feature, then run it again with Select Polyline, the Erase the polyline.

Obviously there might be cleaner code than doing everything through the command line, but hell, it's quick & simple!
Yeah, this is one option I have considered, but using this method I have to first determine if the Xref is clipped or not, there may be hundreds of xrefs to deal with and this is selecting all of them.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: XClipping
« Reply #3 on: August 17, 2011, 01:22:40 PM »
Just a "stab in the dark" ... run the XClip command with its Generate Polyline feature, then run it again with Select Polyline, the Erase the polyline.

Obviously there might be cleaner code than doing everything through the command line, but hell, it's quick & simple!
Yeah, this is one option I have considered, but using this method I have to first determine if the Xref is clipped or not, there may be hundreds of xrefs to deal with and this is selecting all of them.
Ummm... have you tried minimize the number of xrefs in a drawing??   :-o


 :-)
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: XClipping
« Reply #4 on: August 17, 2011, 01:27:33 PM »
Well, just as a "quick" check ... save (entlast) to a variable, then call the XClip command to generate the polyline. Check the new entlast against the one saved in the variable. If they're the same, then the xref didn't have a clip.

Sorry, haven't got my ACad open just now. You can always try to drill down into the xref insert's DXF codes through VLIDE. Or use my DictEdit routine here ... there's a secondary command called RawDisplay. If you can't get at something like that (which I'd guess would be a dictionary attached to the Insert entity), then there's no way to programatically do it from Lisp.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: XClipping
« Reply #5 on: August 17, 2011, 01:41:21 PM »
A start (sorry, no time) ... old (2000) code, so ugly / unproven of late ...

Code: [Select]
(defun _get_xclip_points ( ename / ename2 data )

    (while (setq ename2 (cdr (assoc 360 (entget ename)))) (setq ename ename2))
   
    (if (member '(0 . "SPATIAL_FILTER") (setq data (entget ename)))
        (cons
            (eq 1 (cdr (assoc 71 data)))
            (apply 'append
                (mapcar
                    (function (lambda ( x ) (if (eq 10 (car x)) (list (cdr x)))))
                    data
                )
            )
        )
    )
)

Returns '(flag point point point)

Clip on: (T (670466.0 678736.0) (671585.0 678520.0) ...)
Clip off: (nil (670466.0 678736.0) (671585.0 678520.0) ...)
No clip: nil
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: XClipping
« Reply #6 on: August 17, 2011, 01:51:14 PM »
Just a "stab in the dark" ... run the XClip command with its Generate Polyline feature, then run it again with Select Polyline, the Erase the polyline.

Obviously there might be cleaner code than doing everything through the command line, but hell, it's quick & simple!
Yeah, this is one option I have considered, but using this method I have to first determine if the Xref is clipped or not, there may be hundreds of xrefs to deal with and this is selecting all of them.
Ummm... have you tried minimize the number of xrefs in a drawing??   :-o


 :-)

They are not my drawings, these are drawings we get from Architects and such, so unfortunately this is not a possible solution, although I wish it were. What I am doing is working on a routine that will change all Xrefs from Overlay->Attach or Attach->Overlay, I have a routine that does this, but it is slow and a bit buggy, so I am trying to remove as many of the bugs as I can.

Ok, that gets me a start, thank you, I will now need to figure out how I am going to apply that boundary, I guess the first step is to determine how many points, so I know if it is a polygonal clip or a rectangular clip.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: XClipping
« Reply #7 on: August 17, 2011, 01:52:33 PM »
A start (sorry, no time) ... old (2000) code, so ugly / unproven of late ...

Code: [Select]
(defun _get_xclip_points ( ename / ename2 data )

    (while (setq ename2 (cdr (assoc 360 (entget ename)))) (setq ename ename2))
   
    (if (member '(0 . "SPATIAL_FILTER") (setq data (entget ename)))
        (cons
            (eq 1 (cdr (assoc 71 data)))
            (apply 'append
                (mapcar
                    (function (lambda ( x ) (if (eq 10 (car x)) (list (cdr x)))))
                    data
                )
            )
        )
    )
)

Returns '(flag point point point)

Clip on: (T (670466.0 678736.0) (671585.0 678520.0) ...)
Clip off: (nil (670466.0 678736.0) (671585.0 678520.0) ...)
No clip: nil
:kewl:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: XClipping
« Reply #8 on: August 17, 2011, 01:54:53 PM »
It's a pretty good start.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: XClipping
« Reply #9 on: August 17, 2011, 01:56:57 PM »
Hmm, doesn't seem to be working with Polygonal clips though.

Quick test: Just tried it on a block with a polygonal xclip (AutoCAD 2010) and it worked. *shrug*
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: XClipping
« Reply #10 on: August 17, 2011, 01:57:40 PM »
Hmm, doesn't seem to be working with Polygonal clips though.

Quick test: Just tried it on a block with a polygonal xclip (AutoCAD 2010) and it worked. *shrug*
Yeah, that one was a problem with my drawing, sorry.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: XClipping
« Reply #11 on: August 17, 2011, 01:58:27 PM »
No worries. PS: Thanks Alan. :)

Back to the land of dreams ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: XClipping
« Reply #12 on: August 17, 2011, 01:58:37 PM »
Hmm, doesn't seem to be working with Polygonal clips though.

Quick test: Just tried it on a block with a polygonal xclip (AutoCAD 2010) and it worked. *shrug*
Works in 2011.

No worries. PS: Thanks Alan. :)

No, thank you. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: XClipping
« Reply #13 on: August 17, 2011, 02:38:34 PM »
Thank you all, that did the trick, a few more tweaks and I will be good to go.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: XClipping
« Reply #14 on: August 17, 2011, 02:40:08 PM »
A start (sorry, no time) ... old (2000) code, so ugly / unproven of late ...

A great start  8-)

Since the XClip boundary is defined in WCS at 1:1 scale and zero rotation, here is a possible extension:

Code: [Select]
(defun _XClipBoundary ( ename / __XClipBoundary elist xlist _xang _xnor )

    (defun __XClipBoundary ( ename / xdict )
        (if
            (setq xdict (cdr (assoc 360 (entget ename))))
            (__XClipBoundary xdict)
            (if
                (and
                    (eq "SPATIAL_FILTER" (cdr (assoc 0 (setq ename (entget ename)))))
                    (eq 1 (cdr (assoc 71 ename)))
                )
                (
                    (lambda ( massoc ) (massoc 10 ename))
                    (lambda ( key elist / item )
                        (if (setq item (assoc key elist))
                            (cons (cdr item) (massoc key (cdr (member item elist))))
                        )
                    )
                )
            )
        )
    )

    (defun __dxf ( key lst ) (cdr (assoc key lst)))

    (setq elist (entget ename)
          _xang (__dxf  50 elist)
          _xnor (__dxf 210 elist)
    )
    (if (setq xlist (__XClipBoundary ename))
        (
            (lambda ( matrix )
                (
                    (lambda ( vector )
                        (mapcar
                            (function
                                (lambda ( point )
                                    (mapcar '+ (mxv matrix point) vector)
                                )
                            )
                            xlist
                        )
                    )
                    (mapcar '- (trans (__dxf 10 elist) _xnor 0)
                        (mxv matrix
                             (__dxf 10 (tblsearch "BLOCK" (__dxf 2 elist)))
                        )
                    )
                )
            )
            (mxm
                (mapcar
                    (function
                        (lambda ( v ) (trans v 0 _xnor t))
                    )
                   '(
                        (1.0 0.0 0.0)
                        (0.0 1.0 0.0)
                        (0.0 0.0 1.0)
                    )
                )
                (mxm
                    (list
                        (list (cos _xang) (sin (- _xang)) 0.0)
                        (list (sin _xang) (cos _xang)     0.0)
                        (list 0.0         0.0             1.0)
                    )
                    (list
                        (list (__dxf 41 elist) 0.0 0.0)
                        (list 0.0 (__dxf 42 elist) 0.0)
                        (list 0.0 0.0 (__dxf 43 elist))
                    )
                )
            )           
        )
    )
)


;; 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)))