Jump to content

Recommended Posts

Posted

Hi

 

the most time consuming task in writing polar function is to find and write information for each needed point. why not to write a lisp routine that write a polar function for us?

 

just draw whatever you want, and ask lisp to get all the needed information from the drawing database, and than ask lisp to generate the code in external text file.

 

WUSIWUG editors were doing it for HTML in the past…

Tell me that I didn’t invent the wheel or give me a novel price :twisted:

 

Shay

Posted

Hi

The geometry is not fixed but the logic behind the drawing task is repetitive.

For sure I would write a code that will draw geometry based on the decision it makes.

 

What im saying is to write a function that translates the data stored in the drawing database to usable polar function.

 

Why im not writing it than...you might ask? Because I believe someone already wrote it, but I cant find it

 

Shay

Posted
The geometry is not fixed but the logic behind the drawing task is repetitive.

For sure I would write a code that will draw geometry based on the decision it makes.

 

If the geometry is not fixed, how would automatic generation of polar expressions help in any way? Reading the drawing database into a set of polar expressions would be no different to simply outputting a set of coordinates...

 

For example, for straight-segmented LWPolylines:

(defun c:poly2polar ( / e )
   (if (setq e (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
       (foreach x (entget (ssname e 0))
           (if (= 10 (car x))
               (princ
                   (strcat "\n(polar '(0.0 0.0) "
                       (rtos (angle    '(0.0 0.0) (cdr x)) 2  " "
                       (rtos (distance '(0.0 0.0) (cdr x)) 2  ")"
                   )
               )
           )
       )
   )
   (princ)
)

Though, this is no different from simply outputting:

(defun c:poly2polar ( / e )
   (if (setq e (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
       (foreach x (entget (ssname e 0))
           (if (= 10 (car x)) (print (cdr x)))
       )
   )
   (princ)
)

Only the points are now defined in cartesian rather than polar.

 

If the aim is to produce code that will recreate the geometry without using an external block, you are far better off using entmake[x] in conjunction with the DXF data output for the entity, e.g.:

 

(defun c:test ( / fn fo in ss )
   (and
       (setq ss (ssget))
       (setq fn (getfiled "" "" "lsp" 1))
       (setq fo (open fn "w"))
       (write-line "(defun c:test1 ( )" fo)
       (repeat (setq in (sslength ss))
           (write-line "    (entmakex\n       '(" fo)
           (foreach x (entget (ssname ss (setq in (1- in))))
               (if (/= 'ename (type (cdr x)))
                   (write-line (strcat "            " (vl-prin1-to-string x)) fo)
               )
           )
           (write-line "        )\n    )" fo)
       )
       (write-line "    (princ)\n)" fo)
       (not (close fo))
       (startapp "notepad" fn)
   )
   (princ)
)

I remember discussing this somewhere before... hopefully this thread won't escalate quite as quickly o:)

Posted

Is that not what's called a macro !!!

 

 

Yeah about time Autodesk get the macro function to actually be use full. Ps Karelcad writes .net code.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...