Author Topic: R12 polylines  (Read 7589 times)

0 Members and 1 Guest are viewing this topic.

jbaxter

  • Guest
R12 polylines
« on: September 18, 2006, 07:38:57 PM »
Greetings,

I want to produce a set of polyline contours in an old copy of R12c3 acad identical to that which I have in R2002.

I do not want to do a DXF transfer or saveasr12 because along with the file comes a buch of stuff that upsets a particular addon in r12 that I want to use.

Is there a way to extract with r2002 using say a script file to produce the contours and then use that script file within r12? I am thinking something that picks up on the vertex points of the countours, these are 2d polylines.

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #1 on: September 18, 2006, 08:34:14 PM »
Here's a start for you. I've got to run, but this creates a file with the required entity list data that can be read into R12 to (entmake) the plines. I haven't yet tested the import part, but I think it should work rather easily....when reading each line from the file you will need to convert from the string to a list.....

Code: [Select]
removed in favor of code posted later on.....
« Last Edit: September 19, 2006, 06:20:24 PM by Jeff_M »

jbaxter

  • Guest
Re: R12 polylines
« Reply #2 on: September 19, 2006, 02:45:46 AM »
Thank you Jeff, I will give it a try and let you know.

Your help with this is much appreciated. I am attempting to take out the digitising process to get the lines into r12 when I already have them within 2002.

I will let you know how I go.

Regards,
John

jbaxter

  • Guest
Re: R12 polylines
« Reply #3 on: September 19, 2006, 02:49:08 AM »
Hi Jeff,

I am getting a syntax error as below:

regards,
JB



Command: appload
Export2r12.lsp successfully loaded.


Command:
Select objects: c

Specify first corner: Specify opposite corner: 181 found

Select objects:



extra right paren on input
Command:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: R12 polylines
« Reply #4 on: September 19, 2006, 03:56:28 AM »
John, Jeff's parenthesis match, have you checked that you copied the post intact ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #5 on: September 19, 2006, 11:12:01 AM »
Well, I knew I was in too much of a hurry last night. Although the code I posted does work with old-style plines (thanks for checking the parenthesis matching, Kerry) I forgot to include the code that converts LWPlines to 2d plines......I'll work on that and the import routine later on.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #6 on: September 19, 2006, 06:24:34 PM »
Here's the revised code that I tested with LWPlines and 2d plines. I can output from R2002 and import back into 2002. I do not have R12 installed to test it there, however. I do believe it will work, as I've stripped off any codes that I think were not available in R12.
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:\\plinexport.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:\\plinexport.txt" "R"))
    (progn
      (while (setq line (read-line ffile))
(entmake (read line))
)
      (close ffile)
      )
    )
  )

jbaxter

  • Guest
Re: R12 polylines
« Reply #7 on: September 19, 2006, 07:37:51 PM »
Thanks Jeff & Kerry, I will give it a whirl.

I have a terrain modelling suite of routines that was designed by a company that has long since gone belly up but the output mesh from it using r12 pure linework is sensational and have not seen anything to match it in todays software so want to keep using it. I have tried all kinds of dxf transfer and others, even taken dxf into ms-word and stripped out the first 17 pages of r2000 stuff and then other entries that are there although supposedly an r12 dxf file output.

My thinking here is that if I can get the r2002 contours into the r12 screen and they are what r12 would produce itself then the programs may work for me hopefully.

I will let you know.

Regards,
JB




Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #8 on: September 19, 2006, 07:43:20 PM »
Ya know, I thought that this sounded familiar. I was in on trying some other workarounds sometime ago. I don't think this was an approach we tried, though!

Good Luck, I'll cross my fingers for you!

BTW, could you share a drawing or data that this software creates? Have you compared it to what Civil3D outputs?

jbaxter

  • Guest
Re: R12 polylines
« Reply #9 on: September 19, 2006, 08:04:28 PM »
Hi,

Not sure what I am doing wrong here but the lisp loads as below but do not seem to be able to invoke it to select my contours.

I will upload a mesh of golf green for you. The software I have centres around creating meshes that remember the momentum of contours and rounds off tops of mounds and bottoms of pits like bunkers without extra work to add contours etc.,very handy but not user friendly:-)

Regards,
John

--------------------------------------------------------------------------------------------

Command: (LOAD "D:/Lisp/Exportplinestor12.lsp") IMPORTPLINESTOR12

Command: exportplinestor12
Unknown command "EXPORTPLINESTOR12".  Press F1 for help.

LE

  • Guest
Re: R12 polylines
« Reply #10 on: September 19, 2006, 10:45:44 PM »
Add a command like:

Code: [Select]
(defun C:XPOLS () (exportplinestor12) (princ)) (princ)

jbaxter

  • Guest
Re: R12 polylines
« Reply #11 on: September 20, 2006, 04:36:05 AM »
Hi Le,

I am not very lisp literate, where does this string get added to the code?

Regards,
John

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: R12 polylines
« Reply #12 on: September 20, 2006, 05:03:06 AM »
Hi Le,

I am not very lisp literate, where does this string get added to the code?

Regards,
John
Code: [Select]
(defun C:XPOLS () (exportplinestor12) (princ))
;;
(defun exportplinestor12 (/ ss idx ffile ent elist)
  (if (setq ss (ssget '((0 . "*POLYLINE"))))

;; ... >>>
;;
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jbaxter

  • Guest
Re: R12 polylines
« Reply #13 on: September 20, 2006, 08:47:30 AM »
Thanks Kerry, I will add that line and give it a go.

Regards,
JB

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #14 on: September 20, 2006, 03:25:35 PM »
Thanks LE & KB for picking up my slack. John, in addition to what they said, you can invoke those functions direct like so:

Command: (exportplinestor12)
Command: (importplinestor12)

jbaxter

  • Guest
Re: R12 polylines
« Reply #15 on: September 21, 2006, 11:24:59 PM »
Thanks Jeff,

I have not as yet attempted to import into r12 (r12 machine not in the office with me as it is at home ready for me to overcome this problem:-) however when I exported contours out of 2002 and then for interest sake did an import back into the same r2002 drawing  I got an interesting result, the unsmoothed contours came in okay however were not exactly over the top of the original contours (offset?) and the spline smoothed original contours ended as a mess of zig-zags when imported.

I think this is on the right track though and worth pursuing I think.

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #16 on: September 23, 2006, 03:42:55 PM »
Hi John,
Could you post your drawing? I just tested, again, with straight LWPlines, arced LWPlines, Curve-fit plines and Spline-fit plines. Every one of them came back in exactly on top of the original. IOW, I haven't been able to duplicate the issues you brought up, but would like to figure out why.....

jbaxter

  • Guest
Re: R12 polylines
« Reply #17 on: September 25, 2006, 12:51:42 AM »
Hi Jeff,

Here are the contours, before and after.

regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #18 on: September 25, 2006, 12:20:35 PM »
OK, I see that I forgot that coordinates don't get output correctly in a normal list listing.......this revised code works on your BEFORE drawing quite well.
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:\\plinexport.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))))))
  (setq assoc10 (cdr (assoc 10 elist)))
  (setq elist (vl-remove (assoc 10 elist) elist))
  (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))
    )
  (setq line2write (vl-prin1-to-string elist))
  (setq line2write (strcat (substr line2write 1 (1- (strlen line2write)))
   " (10 "
     (rtos (car assoc10) 2 8)
   " "
     (rtos (cadr assoc10) 2 8)
   " "
     (rtos (caddr assoc10) 2 8)
     "))"      
   ))
  (write-line line2write ffile)
  (setq ent (entnext ent))
  )
(write-line (vl-prin1-to-string elist) ffile)
)
      (close ffile)
      (command "_undo" "_end")
      (command "u")
      )
    )
  )
I should note that the import function will not work correctly when you are importing into a drawing that does not have the linetypes defined in it that the plines use. As that is something that can be checked/coded fairly easily I'll leave that for you to do. If it were me, I'd just change them all to bylayer before exporting.

jbaxter

  • Guest
Re: R12 polylines
« Reply #19 on: September 25, 2006, 07:43:44 PM »
Thank you for your time on this Jeff, I will give it a go today.

Regards,
JB

jbaxter

  • Guest
Re: R12 polylines
« Reply #20 on: September 25, 2006, 11:32:30 PM »
Hi Jeff,

That worked fine exporting and re-inserting back into r2002, I will set it up for R12 and give that a try and let you know.

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #21 on: September 28, 2006, 02:13:01 PM »
....., I will set it up for R12 and give that a try and let you know.

Regards,
John
Well? I'm curious and I can't find a computer around here with a floppy drive so I can't install R12 to try it myself.

jbaxter

  • Guest
Re: R12 polylines
« Reply #22 on: January 08, 2007, 08:06:02 AM »
Hi Jeff,

I am back at this again. :-)

I am using a pure dos system with r12 acad installed so the old 8.3 filenames are imposed, I think that is stopping the importplinestor12 command from working as I am getting an unknown command error.

Regards,
John


Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #23 on: January 08, 2007, 01:50:47 PM »
Hi John,
You will need to refresh your memory on how to implement the utilities. :-) I know I did.....

Look back 9-10 messages and see that I did not set these up to be commands, but rather they are functions and need to be issued like so:

Command: (importplinestor12)

Hope that works, as I don't recall there being a limitation on the length of function names.

jbaxter

  • Guest
Re: R12 polylines
« Reply #24 on: January 08, 2007, 11:44:57 PM »
Hi Jeff,

Yep I dare say I could use a refresher on r12 stuff  :-) however I am invoking with (importplinestor12) but is returning NIL at the command prompt within R12?

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #25 on: January 09, 2007, 12:11:55 AM »
Hi John,
It should return nil, but I should have had it return T if successful or nil if not. Did you try to ZOOM Extents to see if the plines were imported?
Code: [Select]
(defun importplinestor12 (/ ffile line)
  (if (setq ffile (open "c:\\plinexport.txt" "R"))
    (progn
      (while (setq line (read-line ffile))
(entmake (read line))
)
      (close ffile)
      T
      )
    (princ "\n...file to import not found....")
    )
  )
Sorry, without R12 here I'm really just grasping at straws......

Jeff

jbaxter

  • Guest
Re: R12 polylines
« Reply #26 on: January 09, 2007, 02:24:01 AM »
Hi Jeff,

I really appreciate your help with this, I know it is difficult when you cannot test it.

I think we are sneaking up on it. I will give the code a try tonight and let you know how it goes. I still there is an issue with the 8.3 rule as a dos system will change the filename to plineexp~1.txt and I think would upset the lisp file call function, anyway I will fiddle around with it and see if I can get it to work.

Does renaming the plinexport.txt to .scr and using the script command to open the linework have any merit? :-o

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #27 on: January 09, 2007, 01:18:48 PM »
DOH! I didn't notice that part of it.....Yes, that file will need to be renamed or the lisp needs to be modified to:
(if (setq ffile (open "c:\\plinex~1.txt" "R"))

No, the scr won't work (I think).

jbaxter

  • Guest
Re: R12 polylines
« Reply #28 on: January 09, 2007, 07:19:02 PM »
Hi Jeff,

I have the txt file residing in the root directory of drive c: however the (importplinestor12) keeps telling me that "file not found" ??? both filenames in the lisp code and file are identical.

Regards,
John

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #29 on: January 09, 2007, 08:18:27 PM »
Can you manually rename the txt file to "plines.txt" and change the (importplinestor12) function to look for "plines.txt"?

Also, I just found my old R10 autolisp manual. I see that (open) requires the mode flag to be lowercase. It doesn't appear that there is a limit to the length of a function name...the GardenPath in the tutorial has a function consisting of 9 letters.

But, there was no (entmake) in R10....wow....

jbaxter

  • Guest
Re: R12 polylines
« Reply #30 on: January 09, 2007, 08:53:19 PM »
Okay, will try it.

Regards,
JB

jbaxter

  • Guest
Re: R12 polylines
« Reply #31 on: January 09, 2007, 11:48:53 PM »
Hi Jeff,

Have not tried it yet but changing the filenames to pline.txt may not help as I have already changed to plinexpt.txt and still returned "file not found".

The import feature without any problem within acad2002, could there be something in r12 that is preventing the path search to the root directory?

Regards,
JB

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #32 on: January 10, 2007, 12:53:58 PM »
John, the only thing that I can think of is what I mentioned in my last post.....R10 requires the mode to be listed in lowercase, so try changing the "R" in the open statement to "r". Other than that, I'm at a loss......

At the command line you could try this to make sure the file is found:
(findfile "c:\\plinexpt.txt")
If found the path will be returned and that isn't the problem, else it will return nil

jbaxter

  • Guest
Re: R12 polylines
« Reply #33 on: January 10, 2007, 05:24:59 PM »
Hi Jeff,

Okay, I understand what you mean by mode now, I will check that out and try the find statement.

Regards,
John

jbaxter

  • Guest
Re: R12 polylines
« Reply #34 on: January 14, 2007, 09:40:39 PM »
SUCCESS AT LAST!!! :-D

Hi Jeff,

The mode thing and the 8.3 dos filename worked for me and can now import the linework into r12 from acad2000 and satisy the terrain modeling program's requirements.

Thanks to you and all the others for your help, really has saved me a lot of digitising work.

Regards,
JB

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: R12 polylines
« Reply #35 on: January 14, 2007, 10:35:36 PM »
Excellent! I'm glad it finally did what you need.