Author Topic: ( Challenge ) How fast can you convert these?  (Read 26719 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: ( Challenge ) How fast can you convert these?
« Reply #15 on: December 05, 2008, 11:11:36 AM »
Hey Matt this is a LISP forum.
 :evil:
I know.  Just offering up an alternative.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: ( Challenge ) How fast can you convert these?
« Reply #16 on: December 05, 2008, 11:14:09 AM »
another way.. not fast though

Code: [Select]
(defun c:doit ( /  activedocument e iacadapplication modelspace)
 (vl-load-com)
  (setq IAcadApplication (vlax-get-acad-object)
ActiveDocument (vla-get-ActiveDocument IAcadApplication)
ModelSpace (vla-get-ModelSpace ActiveDocument)
  )
  (vlax-for e ModelSpace
     (vla-Addcircle ModelSpace (vla-get-Coordinates e) 15)
       (vla-Erase e))
)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: ( Challenge ) How fast can you convert these?
« Reply #17 on: December 05, 2008, 11:17:52 AM »
Daniel that is basically the same as Matts code, but offers more overhead due to the interpretive nature of lisp.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: ( Challenge ) How fast can you convert these?
« Reply #18 on: December 05, 2008, 11:18:29 AM »
Daniel that is basically the same as Matts code, but offers more overhead due to the interpretive nature of lisp.

correct.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ( Challenge ) How fast can you convert these?
« Reply #19 on: December 05, 2008, 11:28:15 AM »
Code: [Select]
(defun c:test (/ *time* n ss)
  (setq *time* (getvar 'millisecs)
ss     (ssget "_x" '((0 . "POINT")))
n      -1
  )
  (repeat (sslength ss)
    (entmakex
      (list '(0 . "CIRCLE")
    '(62 . 1)
    (cons 10
  (cdr (assoc 10 (entget (ssname ss (setq n (1+ n))))))
    )
    '(40 . 1.0)
      )
    )
  )
  (princ
    (strcat "\n < Elapsed time: "
    (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
    " seconds. > "
    )
  )
)

Why this --

Code: [Select]
      (list '(0 . "CIRCLE")
    '(62 . 1)
    (cons 10
  (cdr (assoc 10 (entget (ssname ss (setq n (1+ n))))))
    )
    '(40 . 1.0)
      )

When you could do this --

Code: [Select]
      (list '(0 . "CIRCLE")
    '(62 . 1)
             (assoc 10 (entget (ssname ss (setq n (1+ n)))))
    '(40 . 1.0)
      )

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

ronjonp

  • Needs a day job
  • Posts: 7526
Re: ( Challenge ) How fast can you convert these?
« Reply #20 on: December 05, 2008, 11:31:56 AM »
You are correct MP...too much coffee this morning   :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ( Challenge ) How fast can you convert these?
« Reply #21 on: December 05, 2008, 11:34:39 AM »
...too much coffee this morning   :-)

That never happens to me. :whistle:

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

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: ( Challenge ) How fast can you convert these?
« Reply #22 on: December 05, 2008, 11:48:51 AM »
well, it's slower but works more like 'convert', preserving layer and color and maybe smth else :)
Code: [Select]
(defun c:test3 (/ ss *time* n EntName)
  (setq *time* (getvar 'millisecs)
ss     (ssget "_x" '((0 . "POINT")))
n      -1
  )
  (while (setq EntName (ssname ss (setq n (1+ n))))
    (entmakex
      (subst '(40 . 1.0)
     '(50 . 0.0)
     (subst '(0 . "CIRCLE") '(0 . "POINT") (entget EntName))
      )
    )
;;;    (entdel EntName)
  )
  (princ
    (strcat "\n < Elapsed time: "
    (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
    " seconds. > "
    )
  )
)

Spike Wilbury

  • Guest
Re: ( Challenge ) How fast can you convert these?
« Reply #23 on: December 05, 2008, 12:58:58 PM »
have been a while.... don't know if say something, but was able to play with very simple coding, and doing some minor changes to the code (ok no erase of the points so, no idea if this counts, but was fun)

;;  < Elapsed time: 1.703000 seconds. >

Code: [Select]
;;  < Elapsed time: 2.454000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (while (< i  (sslength ss))
;;; (setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmake
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbEntity")
;;; '(67 . 0)
;;; '(410 . "Model")
;;; '(8 . "0")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; '(210 0.0 0.0 1.0)))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )


;; < Elapsed time: 2.016000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (while (< i  (sslength ss))
;;; (setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmake
;;;   (list '(0 . "CIRCLE")
;;; ;;'(100 . "AcDbEntity")
;;; ;;'(67 . 0)
;;; ;;'(410 . "Model")
;;; ;;'(8 . "0")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; ;;'(210 0.0 0.0 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.938000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (while (< i  (sslength ss))
;;; (setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmakex
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.890000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (setq num (sslength ss))
;;;      (while (< i num) ;;(< i  (sslength ss))
;;; (setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmakex
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.953000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (setq num (sslength ss))
;;;      (while (< i num)
;;; (setq ename (ssname ss i))
;;; (setq lst (entget ename))
;;; (setq pt (cdr (assoc 10 lst)))
;;; (entmakex
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.860000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (setq num (sslength ss))
;;;      (repeat num
;;; (setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmakex
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbCircle")
;;; (cons 10 pt)
;;; '(40 . 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.859000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (setq num (sslength ss))
;;;      (repeat num
;;; ;;(setq pt (cdr (assoc 10 (entget (ssname ss i)))))
;;; (entmakex
;;;   (list '(0 . "CIRCLE")
;;; '(100 . "AcDbCircle")
;;; (cons 10 (cdr (assoc 10 (entget (ssname ss i)))))
;;; '(40 . 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.765000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i 0)
;;;      (setq num (sslength ss))
;;;      (repeat num
;;; (entmakex
;;;   (list (cons 0 "CIRCLE")
;;; (cons 100 "AcDbCircle")
;;; (cons 10 (cdr (assoc 10 (entget (ssname ss i)))))
;;; (cons 40 1.0)
;;; ))
;;; (setq i (1+ i))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

;;  < Elapsed time: 1.703000 seconds. >
(defun C:TST  (/ ss i pt)
  (setq *time* (getvar 'millisecs))
  (if (setq ss (ssget "x" '((0 . "point"))))
    (progn
      (setq i -1)
      (setq num (sslength ss))
      (repeat num
(entmakex
  (list (cons 0 "CIRCLE")
(cons 100 "AcDbCircle")
(cons 10 (cdr (assoc 10 (entget (ssname ss (setq i (1+ i)))))))
(cons 40 1.0)))
)
      ))
  (princ
    (strcat "\n < Elapsed time: "
    (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
    " seconds. > "
    )
    )
  (princ)
  )

;;  < Elapsed time: 1.734000 seconds. >
;;;(defun C:TST  (/ ss i pt)
;;;  (setq *time* (getvar 'millisecs))
;;;  (if (setq ss (ssget "x" '((0 . "point"))))
;;;    (progn
;;;      (setq i -1 num (sslength ss))
;;;      (repeat num
;;; (entmakex
;;;   (list (cons 0 "CIRCLE")
;;; (cons 100 "AcDbCircle")
;;; (cons 10 (cdr (assoc 10 (entget (ssname ss (setq i (1+ i)))))))
;;; (cons 40 1.0)
;;; ))
;;; )
;;;      ))
;;;  (princ
;;;    (strcat "\n < Elapsed time: "
;;;     (rtos (/ (- (getvar 'millisecs) *time*) 1000.0) 2 6)
;;;     " seconds. > "
;;;     )
;;;    )
;;;  (princ)
;;;  )

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: ( Challenge ) How fast can you convert these?
« Reply #24 on: December 05, 2008, 01:29:49 PM »
Hey Matt this is a LISP forum.
 :evil:
I know.  Just offering up an alternative.

 :wink:

Command: doit
Total running time: 0.28 seconds

Code: [Select]
  typedef AcDbObjectPointer<AcDbPoint> AcDbPointPointer;
  typedef AcDbObjectPointer<AcDbCircle> AcDbCirclePointer;
  static void CRPDArxConvert_doit(void)
  {
    CLapseTime ltTotal;
    Acad::ErrorStatus es;
    long ssLength = 0;

    ads_name sel;
    AcDbObjectIdArray ids;

    resbuf *rbFilter = acutBuildList(RTDXF0, _T("POINT"), RTNONE);
    TCHAR* mode = _T("X");

    if (acedSSGet(mode, NULL, NULL, rbFilter, sel) != RTNORM)
    {
      acutRelRb(rbFilter);
      return;
    }

    if(acedSSLength(sel, &ssLength) != RTNORM || ssLength == 0)
    {
      acedSSFree(sel);
      return;
    }

    if(acedGetCurrentSelectionSet(ids) != Acad::eOk)
    {
      acedSSFree(sel);
      return;
    }

    AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
    AcDbBlockTableRecordPointer pBTR(pDb->currentSpaceId(), AcDb::kForWrite); //<<<<<

    for(int i = 0 ; i < ids.length(); i++)
    {
      AcDbPointPointer smartPointer(ids[i],AcDb::kForRead);
      if(smartPointer.openStatus() == Acad::eOk)
      {
        AcDbCirclePointer pCircle;
        if(pCircle.create() == Acad::eOk)
        {
          pCircle->setRadius(15.0);
          pCircle->setCenter( smartPointer->position());
          pBTR->appendAcDbEntity(pCircle);
          smartPointer->upgradeOpen();
          smartPointer->erase();
        }
      }
    }
    acedSSFree(sel);
    acutRelRb(rbFilter);
    acutPrintf(_T("\nTotal running time: %.4f seconds"), ltTotal.LapseTimeSeconds());
  }
« Last Edit: December 05, 2008, 01:45:14 PM by Daniel »

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: ( Challenge ) How fast can you convert these?
« Reply #25 on: December 05, 2008, 01:31:23 PM »
Hey Matt this is a LISP forum.
 :evil:
I know.  Just offering up an alternative.

 :wink:

Command: doit
Total running time: 0.28 seconds

Oooooohhh... Looks like you win!
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Spike Wilbury

  • Guest
Re: ( Challenge ) How fast can you convert these?
« Reply #26 on: December 05, 2008, 01:35:08 PM »
Code: [Select]
    acedSSFree(sel);
    acutPrintf(_T("\nTotal running time: %.2f seconds"), ltTotal.LapseTimeSeconds());
  }

that's not fair.... for the lisp world.....

ok then, how about a version using a point container iterator...  eh...... and see if lower the time :)

I mean something like:

Code: [Select]
AcDbDatabase* pDb = curDoc()->database();
AcDbBlockTableRecordPointer modelSpace(ACDB_MODEL_SPACE, pDb, AcDb::kForWrite); // and do another for paper_space
if(modelSpace.openStatus() != Acad::eOk) return;

AcDbBlockTableRecordIterator* pIterator = NULL;
modelSpace->newIterator(pIterator);

for (pIterator->start(); !pIterator->done(); pIterator->step())
{
AcDbObjectId objId;
pIterator->getEntityId(objId);
AcDbObjectPointer<AcDbPoint> pointObj(objId, AcDb::kForRead); // open for what?
if (pointObj.openStatus() == Acad::eOk)
{

}
}
delete pIterator;
« Last Edit: December 05, 2008, 01:44:46 PM by Luis »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: ( Challenge ) How fast can you convert these?
« Reply #27 on: December 05, 2008, 01:57:54 PM »
Command: doit
Total running time: 0.2810 seconds
Command: test
Total running time: 0.2180 seconds

Code: [Select]
  static void CRPDArxConvert_test(void)
  {
    CLapseTime ltTotal;
    AcDbObjectId objId;

    AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
    AcDbBlockTableRecordPointer pBTR(pDb->currentSpaceId(), AcDb::kForWrite);
   
    AcDbBlockTableRecordIterator* pIterator = NULL;
    pBTR->newIterator(pIterator);

    for (pIterator->start(); !pIterator->done(); pIterator->step())
    {
      pIterator->getEntityId(objId);
      AcDbObjectPointer<AcDbPoint> smartPointer(objId, AcDb::kForRead);

      if (smartPointer.openStatus() == Acad::eOk)
      {
        AcDbCirclePointer pCircle;
        if(pCircle.create() == Acad::eOk)
        {
          pCircle->setRadius(15.0);
          pCircle->setCenter( smartPointer->position());
          pBTR->appendAcDbEntity(pCircle);
          smartPointer->upgradeOpen();
          smartPointer->erase();
        }
      }
    }
    acutPrintf(_T("\nTotal running time: %.4f seconds"), ltTotal.LapseTimeSeconds());
    delete pIterator;
  }

Spike Wilbury

  • Guest
Re: ( Challenge ) How fast can you convert these?
« Reply #28 on: December 05, 2008, 02:31:18 PM »
Command: test
Total running time: 0.2180 seconds

Good,

Now wait to see the C# (.NET) version..... (hope someone post a sample too).... :)

Swift

  • Swamp Rat
  • Posts: 596
Re: ( Challenge ) How fast can you convert these?
« Reply #29 on: December 05, 2008, 03:14:37 PM »
Off topic, but where did "CLapseTime" come from?