Code Red > AutoLISP (Vanilla / Visual)

Pline Convert: 2004~8 to R12 file

(1/3) > >>

jbaxter:
Greetings,

Mark wrote the routine below for me in order to convert a set of polyline entities to a standard R12 file ready to be submitted to a terrain modeler that I use.

It works great however I am having some compatibility issues with it when working with files from acad 2004 thru 2007/8.

Mark does not have access to the later version acad so cannot adjust the routine for me, I wonder if anyone may be able to take a look at it.

I am thinking that the later versions of acad brings with it some extra code additive that prevents the routine from creating a standard r12 set of linework.

It basically takes a set of contours opened in 2002 (converted) from later acad version and created a TXT file which is then fed into acad r12.

Regards,
John


--- Code: ---(defun exportplinestor12 (/ ss idx ffile ent elist)
  (if (setq ss (ssget '((0 . "*POLYLINE"))))
    (progn
      (command "_undo" "_be")
      (command "_convertpoly" "_h" ss "")
      (setq idx -1
    ffile (open "c:\\plinexpt.txt" "W")
    )
      (while (setq ent (ssname ss (setq idx (1+ idx))))
(while (/= "SEQEND" (cdr (assoc 0 (setq elist (vl-remove-if
'(lambda (x / code)
   (setq code (car x))
   (or (= code -1)
       (= code -2)
       (= code 5)
       (= code 330)
       (= code 340)
       (= code 100)
       (= code 410)
       )
   )
(entget ent))))))
  (if (and (assoc 70 elist)
   (= 128 (logand (cdr (assoc 70 elist)) 128))
   )
    (setq elist (subst (cons 70 (- (cdr (assoc 70 elist)) 128)) (assoc 70 elist) elist))
    )
  (write-line (vl-prin1-to-string elist) ffile)
  (setq ent (entnext ent))
  )
(write-line (vl-prin1-to-string elist) ffile)
)
      (close ffile)
      (command "_undo" "_end")
      (command "u")
      )
    )
  )

(defun importplinestor12 (/ ffile line)
  (if (setq ffile (open "c:\\plinexpt.txt" "r"))
    (progn
      (while (setq line (read-line ffile))
(entmake (read line))
)
      (close ffile)
      )
    )
  )
--- End code ---

CAB:
I'm not familiar with any new dxf codes in the plines but perhaps the reverse of what the routine is doing.
Instead of removing selected dxf codes just keep specific dxf codes.

Jeff_M:
First, that was me, Jeff, who developed that for you :-)

Here's the output from 2002 & 2008 for similar plines.

--- Quote ---2002
((0 . "POLYLINE") (67 . 0) (8 . "0") (66 . 1) (10 0.0 0.0 0.0) (70 . 0) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (75 . 0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1.7833e+006 299520.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1.78343e+006 299687.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1.78372e+006 299707.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1.78396e+006 299660.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "SEQEND") (67 . 0) (8 . "0"))


2008
((0 . "POLYLINE") (67 . 0) (8 . "0") (66 . 1) (10 0.0 0.0 0.0) (70 . 0) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (75 . 0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 686.701 579.105 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 866.889 730.589 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1312.93 805.347 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "VERTEX") (67 . 0) (8 . "0") (10 1618.16 739.442 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
((0 . "SEQEND") (67 . 0) (8 . "0"))

--- End quote ---
As you can see, they have identical (assoc) pairs. Could you post a drawing that exhibits the problem?

jbaxter:
Hi jeff,

I am very embarrassed that i confused the author, apologies for that.

I have attached here a sample set of contours that seem to be a problem.

The exportplinestor12 routine has really been great for me, thank you again for helping me with that.


Regards,
John

Jeff_M:
No problem, John.

The problem with these contours (or at least some of them) is that when the linetypescale is not 1 for the pline then a new dxf code is added that R12 doesn't know about. I'm think CAB's suggestion of including just those codes we DO want might be the answer....except that we are using 3 entity types whose good codes vary. So, for now, just adding one more check to the (or ....) section of code will do the trick. Just insert this after the (= code 410) line.
(= code 48)

I think that should do it.

Navigation

[0] Message Index

[#] Next page

Go to full version