Author Topic: Pline Convert: 2004~8 to R12 file  (Read 2144 times)

0 Members and 1 Guest are viewing this topic.

jbaxter

  • Guest
Pline Convert: 2004~8 to R12 file
« on: January 07, 2008, 07:57:28 AM »
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: [Select]
(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)
      )
    )
  )
« Last Edit: January 07, 2008, 01:32:18 PM by CAB »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: 2004~8 to R12 file
« Reply #1 on: January 07, 2008, 10:36:28 AM »
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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: 2004~8 to R12 file
« Reply #2 on: January 07, 2008, 01:50:38 PM »
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"))
As you can see, they have identical (assoc) pairs. Could you post a drawing that exhibits the problem?

jbaxter

  • Guest
Re: Pline Convert: 2004~8 to R12 file
« Reply #3 on: January 07, 2008, 04:41:21 PM »
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

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Pline Convert: 2004~8 to R12 file
« Reply #4 on: January 07, 2008, 05:55:50 PM »
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.

jbaxter

  • Guest
Re: Pline Convert: 2004~8 to R12 file
« Reply #5 on: January 07, 2008, 06:14:59 PM »
Thanks Jeff,

I will add the entry and give it a try today on a set of contours.

Thanks for your help with this.

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Pline Convert: 2004~8 to R12 file
« Reply #6 on: January 07, 2008, 06:33:15 PM »
You're welcome. One thing I forgot to check until after I posted was that the linetype scale was a part of the entities in r2000 as well, so this should have come up even when used in 2002. But that is the only thing I can find that would make it not work when importing to R12.

jbaxter

  • Guest
Re: Pline Convert: 2004~8 to R12 file
« Reply #7 on: January 07, 2008, 06:41:38 PM »
Hi Jeff,

I have probably just been lucky that the ltscale has been 1, I will check out the 2008 contours I have been sent and check the ltscale.

Thanks,
JB

jbaxter

  • Guest
Re: Pline Convert: 2004~8 to R12 file
« Reply #8 on: January 07, 2008, 08:42:14 PM »
IT WORKED!!!!

Thanks Jeff, your a life saver. :-)

I added the entry and changed ltscale for the linework to 1 and the resulting dxf file satisfied the program input.

I have created a mesh this morning and attach it here, it is the result of the 2004+ contours.

Regards,
JB

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Pline Convert: 2004~8 to R12 file
« Reply #9 on: January 07, 2008, 09:51:38 PM »
Great! You're most welcome.

However......the change to the code was so that you didn't need to worry about the ltscale. :-)

That's a good looking mesh!
 

jbaxter

  • Guest
Re: Pline Convert: 2004~8 to R12 file
« Reply #10 on: January 07, 2008, 09:55:33 PM »
Thanks Jeff, the old R12 dos DTM is an oldie but a goodie, just like me. :-)

Regards,
JB