Author Topic: DataExtraction LISP  (Read 4133 times)

0 Members and 1 Guest are viewing this topic.

jtm2020hyo

  • Newt
  • Posts: 198
DataExtraction LISP
« on: February 18, 2020, 11:47:33 PM »
I have multiple problems with every time that I have a big drawing. everything I need to fix them I need to reinsert the entire drawing using data extraction. so, is very painful, I need to request a lisp to do the same thing that DataExtraction.

So, Is possible to do a reinsert lisp equivalent to DataExtraction with all their properties? or simply do a reinsert.lsp for blocks?

jtm2020hyo

  • Newt
  • Posts: 198
Re: DataExtraction LISP
« Reply #1 on: February 19, 2020, 12:13:42 AM »
I forget to say I need to export the entire drawing.
I can not save the file with another name, I need to fix the blocks and then I need to use dataextraction in the original final and reinsert the blocks with csv file and copy in the command line.

re-insert fix every problem in all the drawings, so I think this will be very useful. my last hope are you guys. I hope any lisp GURU can help me (help the entire world) with this request.

kpblc

  • Bull Frog
  • Posts: 396
Re: DataExtraction LISP
« Reply #2 on: February 19, 2020, 03:33:18 AM »
Perhaps the better way is to use _.wblock ? This will degrag dwg database and (sometimes) it makes dwg file smaller.
Sorry for my English.

jtm2020hyo

  • Newt
  • Posts: 198
Re: DataExtraction LISP
« Reply #3 on: March 14, 2020, 02:33:49 AM »
I just need to reinsert block with same rotate - coordinates - attribute - etc - properties.

... 3 month searching for and 0 results, so, this request is impossible?

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: DataExtraction LISP
« Reply #4 on: March 15, 2020, 04:52:01 AM »
Did you try Wblock ?

Using clip board can copy a entire dwg whats displayed and paste into another new dwg. It can grind a bit and have know it to fail on mega dwgs so do in a couple of goes.
A man who never made a mistake never made anything

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: DataExtraction LISP
« Reply #5 on: March 15, 2020, 11:54:22 AM »
I have multiple problems with every time that I have a big drawing.

1. Define "big" drawing.
2. Have you identified what's causing the problem?
3. Do you have examples of:
    a. "Big" drawing before problems emerge.
    b. Same drawing after problems emerge.

Tx.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

jtm2020hyo

  • Newt
  • Posts: 198
Re: DataExtraction LISP
« Reply #6 on: March 16, 2020, 09:48:15 PM »
Did you try Wblock ?

Using clip board can copy an entire dwg whats displayed and paste into another new dwg. It can grind a bit and have know it to fail on mega dwgs so do in a couple of goes.

... yes, for normal blocks that work. but when I need to copy dynamic block parameters values and attribute values, then the fun start, I need to use dataextraction, create a excel, then insert blocks, if something is wrong, then I need to start again, and again... so the easy way might be just a lisp to re-insert all blocks.

I have multiple problems with every time that I have a big drawing.

1. Define "big" drawing.
2. Have you identified what's causing the problem?
3. Do you have examples of:
    a. "Big" drawing before problems emerge.
    b. Same drawing after problems emerge.

Tx.

here some post where I already request for help for same problem in different ways:

https://forums.autodesk.com/t5/autocad-forum/i-found-2-unfixable-type-of-blocks-maybe-a-bug-autocad-2020/m-p/9305465#M1009368

https://forums.autodesk.com/t5/autocad-forum/i-found-2-unfixable-type-of-blocks-maybe-a-bug-autocad-2020/m-p/9305465#M1009368

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-re-insert-all-blocks-or-fix-mirror-text/m-p/9216652#M394087

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-explode-a-block-scaled-nonuniformly/m-p/9191256#M393442

... all those posts were not resolved. but the positive way is that finally I know how to solve them, RE-INSERT.LSP, the re-insert lisp that works exactly like dataextraction + excel methd might solve that 4 but that I found.

PD: IMO this should be added  to AUTOCAD in way of AUDIT command. if you try solve that 4 bugs, you will find that can be solved with dataextraction (requested RE-insert.lsp)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: DataExtraction LISP
« Reply #7 on: March 17, 2020, 12:42:13 AM »
The following is really crude and complete with warts but it's been a long day and I'm out of gas.

Seems to work on the drawings I tested:

Code: [Select]
(defun c:fixmeyo ( / getbb make fixmeyo ss i )

    (defun getbb ( o / a b )
        (vl-catch-all-apply 'vlax-invoke-method (list o 'getboundingbox 'a 'b))
        (if a (mapcar 'vlax-safearray->list (list a b)))
    )

    (defun make ( d )
        (entmake
            (vl-remove nil
                (mapcar
                   '(lambda ( p / k v )
                        (cond
                            ((eq 'ename (type (setq v (cdr p)))) nil)
                            ((eq 5 (setq k (car p))) nil)
                            ((member k '(41 42 43)) (cons k (abs v)))
                            ((eq 210 k) (cons k (mapcar 'abs v)))
                            (p)
                        )
                    )
                    d
                )
            )   
        )
    )

    (defun fixmeyo ( e / d o b p r a e! o! )
   
        (setq
            d (entget e)
            o (vlax-ename->vla-object e)
            b (getbb o)
            p (vlax-get o 'insertionpoint)
            r (vlax-get o 'rotation)
            a (vl-catch-all-apply 'eval '((mapcar 'vlax-vla-object->ename (vlax-invoke o 'getattributes))))
        )
       
        (if (listp a)
            (progn
                (make d)
                (mapcar 'make (mapcar 'entget a))
                (entmake '((0 . "SEQEND")(100 . "AcDbEntity")(8 . "0")))
            )
            (make d)
        )
       
        (if (/= e (setq e! (entlast)))
            (progn
                (vlax-put (setq o! (vlax-ename->vla-object e!)) 'insertionpoint p)
                (if (not (equal 0.0 r 1.0e-5)) (vlax-put o! 'rotation (+ pi r)))   
                (entdel e)
                (if (vl-some 'minusp (mapcar '(lambda (k) (cdr (assoc k d))) '(41 42 43)))
                    (vlax-put o! 'insertionpoint
                        (mapcar '+
                            (vlax-get o! 'insertionpoint)
                            (mapcar '- (car b) (car (getbb o!)))
                        )
                    )
                )
            )
        )                       
    )
   
    (if (setq ss (ssget "x" '((0 . "insert")(-4 . "<or")(210 0.0 0.0 -1.0)(41 . -1.0)(42 . -1.0)(-4 . "or>"))))
        (repeat (setq i (sslength ss))
            (fixmeyo (ssname ss (setq i (1- i))))
        )
    )
   
    (princ)

)

Use | Abuse | Retry | Abort | Ignore

Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DataExtraction LISP
« Reply #8 on: March 19, 2020, 09:31:12 AM »
A bit sad that the OP does not give an update.


jtm2020hyo

  • Newt
  • Posts: 198
Re: DataExtraction LISP
« Reply #10 on: March 25, 2020, 01:11:41 AM »
A bit sad that the OP does not give an update.

sorry for the late answers. coronavirus times.

I was testing the lisp published but I do nothing, at least I can not show any change. I already tested it in multiple files, no luck.

The following is really crude and complete with warts but it's been a long day and I'm out of gas.

Seems to work on the drawings I tested:

Code: [Select]
(defun c:fixmeyo ( / getbb make fixmeyo ss i )

    (defun getbb ( o / a b )
        (vl-catch-all-apply 'vlax-invoke-method (list o 'getboundingbox 'a 'b))
        (if a (mapcar 'vlax-safearray->list (list a b)))
    )

    (defun make ( d )
        (entmake
            (vl-remove nil
                (mapcar
                   '(lambda ( p / k v )
                        (cond
                            ((eq 'ename (type (setq v (cdr p)))) nil)
                            ((eq 5 (setq k (car p))) nil)
                            ((member k '(41 42 43)) (cons k (abs v)))
                            ((eq 210 k) (cons k (mapcar 'abs v)))
                            (p)
                        )
                    )
                    d
                )
            )   
        )
    )

    (defun fixmeyo ( e / d o b p r a e! o! )
   
        (setq
            d (entget e)
            o (vlax-ename->vla-object e)
            b (getbb o)
            p (vlax-get o 'insertionpoint)
            r (vlax-get o 'rotation)
            a (vl-catch-all-apply 'eval '((mapcar 'vlax-vla-object->ename (vlax-invoke o 'getattributes))))
        )
       
        (if (listp a)
            (progn
                (make d)
                (mapcar 'make (mapcar 'entget a))
                (entmake '((0 . "SEQEND")(100 . "AcDbEntity")(8 . "0")))
            )
            (make d)
        )
       
        (if (/= e (setq e! (entlast)))
            (progn
                (vlax-put (setq o! (vlax-ename->vla-object e!)) 'insertionpoint p)
                (if (not (equal 0.0 r 1.0e-5)) (vlax-put o! 'rotation (+ pi r)))   
                (entdel e)
                (if (vl-some 'minusp (mapcar '(lambda (k) (cdr (assoc k d))) '(41 42 43)))
                    (vlax-put o! 'insertionpoint
                        (mapcar '+
                            (vlax-get o! 'insertionpoint)
                            (mapcar '- (car b) (car (getbb o!)))
                        )
                    )
                )
            )
        )                       
    )
   
    (if (setq ss (ssget "x" '((0 . "insert")(-4 . "<or")(210 0.0 0.0 -1.0)(41 . -1.0)(42 . -1.0)(-4 . "or>"))))
        (repeat (setq i (sslength ss))
            (fixmeyo (ssname ss (setq i (1- i))))
        )
    )
   
    (princ)

)

Use | Abuse | Retry | Abort | Ignore

Cheers.

please, explain us a bit how this lisp works. I did not noticed any change when the lisp is activated.



-------

basically What I tried explain is that is need to replicate, delete selected blocks and reinsert since 0 with same properties, not do ctrl+z or command OOPS, with the next steps:

1 export your data with DATAEXPORT to excel
2 in excel create the multiple commands to copy and paste to AutoCAD for insert the blocks (ATTACHED file)
3 copy all commands to the file and AutoCAD should insert the blocks.

This 3 steps is the unique way that I found to solve all my problems related to the posted bugs. brute froce, but works. the problems is that is very painful to do it everything. so that is the reason to request for help in all forums because I think might help to everyone (specially to me).

---

and where are here, my last hope are you MP, save us of this pain.



MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: DataExtraction LISP
« Reply #11 on: March 25, 2020, 08:31:17 AM »
I don't have time for anything but a quick response.

Based on the drawings provided 3 principle problems existed with some block instances.

1. Negative scales; e.g. -1 , 1, 1
2. Abnormal normal, e.g. 0, 0, -1
3. The insertion point in the ActiveX properties did not match the dxf equivalent (group 10). e.g. (108999.0 488164.0 0.0) vs (-108999.0 488164.0 0.0)

Merely setting the values correctly would result in the original insertion point being lost as well as the relative distance between an associated attribute and its parent insert lost, i.e. existing presentation lost.

Code fixed all the above and restored original presentation.

Two example sickly drawings and their fixes provided.

If you need something else sorry, no time. Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

jtm2020hyo

  • Newt
  • Posts: 198
Re: DataExtraction LISP
« Reply #12 on: March 27, 2020, 09:26:34 PM »
I was testing in the posted drawing. I can confirm this works.

congrats MP, you are the winner. the smartest guru in the lisp world.

thanks a lot. for your help. I hope you do not get coronavirus.

edit:
PD: if I find errors in the future, I will publish it in this post.
« Last Edit: March 27, 2020, 09:34:31 PM by jtm2018hyo »