Author Topic: Get Coordinates in ProgeCAD  (Read 1344 times)

0 Members and 1 Guest are viewing this topic.

codrutbenedic81

  • Mosquito
  • Posts: 6
Get Coordinates in ProgeCAD
« on: February 10, 2023, 02:02:06 AM »
Code - Auto/Visual Lisp: [Select]
  1.     (vl-load-com) ; initialization
  2.      
  3.     (defun c:cgdata (/ xml file)
  4.       (setq fname (getstring "\nNume fisier (ex: filename.xml):"))
  5.       (setq file (open fname "w"))
  6.      
  7.       (write-line "<?xml version=\"1.0\" encoding=\"ANSI\"?>" file)
  8.       (write-line "<CADDATA>" file)
  9.      
  10.       (cgpoly)
  11.       (cgtext)
  12.      
  13.       (write-line "</CADDATA>" file)
  14.       (close file)
  15.      
  16.       (startapp "notepad.exe" fname)
  17.      
  18.       (princ "--->>>The file \"")
  19.       (princ fname)
  20.       (princ "\" has been created.<<<----")
  21.       (princ "\nGeotop, (2018)")
  22.       (print)
  23.      
  24.     ) ;_ end of defun
  25.      
  26.     (defun cgpoly (/ lst ss i en obj)
  27.       (and (setq ss (ssget "X"
  28.               '((0 . "LWPOLYLINE") ; object Name
  29.                 (-4 . "&=") ; bit coded
  30.                 (70 . 1) ; polyline is closed
  31.                )
  32.               )
  33.             )
  34.            
  35.       (repeat (setq i (sslength ss))
  36.         (setq en  (ssname ss (setq i (1- i)))
  37.           obj (vlax-ename->vla-object en)
  38.         )
  39.           (write-line "<LWPOLYGON>" file)
  40.           (write-line (strcat "<LAYER>" (vlax-get obj 'Layer) "</LAYER>") file)
  41.           (write-line (strcat "<HANDLE>" (vlax-get obj 'Handle) "</HANDLE>") file)
  42.           (write-line (strcat "<AREA>" (rtos (vlax-get obj 'Area) 2 4) "</AREA>") file)
  43.           ;----
  44.           (setq lst (vlax-get obj 'Coordinates) idx -1 xy "")
  45.           (repeat (/ (length lst) 2)
  46.             (setq xy (strcat xy (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ", "))
  47.             (setq idx (+ 2 idx))
  48.           )
  49.           (write-line (strcat "<LOCATION>POLYGON((" (vl-string-trim ", " xy) "))</LOCATION>") file)
  50.           ;----
  51.           (write-line "</LWPOLYGON>" file)
  52.         )
  53.       )
  54.     ) ;_ end of defun 'cgpoly'
  55.      
  56.     (defun cgtext (/ lst ss i en obj)
  57.       (and (setq ss (ssget "_X" '((0 . "TEXT,MTEXT"))))
  58.      
  59.       (repeat (setq i (sslength ss))
  60.         (setq en  (ssname ss (setq i (1- i)))
  61.           obj (vlax-ename->vla-object en)
  62.               )
  63.           (write-line "<TEXT>" file)
  64.           (write-line (strcat "<LAYER>" (vlax-get obj 'Layer) "</LAYER>") file)
  65.           (write-line (strcat "<HANDLE>" (vlax-get obj 'Handle) "</HANDLE>") file)
  66.           (write-line (strcat "<VALUE>" (vlax-get obj 'textstring) "</VALUE>") file)
  67.           ;----
  68.           (setq lst (vlax-get obj 'insertionpoint) idx -1 xy "")
  69.           (write-line (strcat "<LOCATION>POINT(" (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ")</LOCATION>") file)
  70.           ;----
  71.           (write-line "</TEXT>" file)
  72.         )
  73.       )
  74.     ) ;_ end of defun 'cgtext'
  75.  
« Last Edit: February 13, 2023, 05:09:05 PM by Ted Striker »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: AutoCAD lisp to ProgeCad lisp
« Reply #1 on: February 10, 2023, 02:14:39 AM »
I remember ProgeCAD, been a while since I’ve played with that one.
Are you getting an error message or something?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: AutoCAD lisp to ProgeCad lisp
« Reply #2 on: February 10, 2023, 06:13:35 AM »
my guess is (vlax-get obj 'Coordinates) is missing from progecad?
but, you should be able to get these from entget, dxf code 10

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: AutoCAD lisp to ProgeCad lisp
« Reply #3 on: February 10, 2023, 06:49:47 AM »
sure they do, all the (10 784590.0 369601.0)(10 784607.0 369603.0) (10 784631.0 369610.0)  ... etc

Code: [Select]
((-1 . <Entity name: 20a4019d270>) (0 . "LWPOLYLINE") (330 . <Entity name: 20a3f544f40>) (5 . "42D3F") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "IMOBIL") (100 . "AcDbPolyline")
(90 . 7) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 784561.0 369594.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 784579.0 369599.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 784590.0 369601.0)
(40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 784607.0 369603.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 784631.0 369610.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 784655.0 369505.0) (40 . 0.0)
(41 . 0.0) (42 . 0.0) (91 . 0) (10 784600.0 369468.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: AutoCAD lisp to ProgeCad lisp
« Reply #4 on: February 10, 2023, 07:10:16 AM »
I'm trying to explain to you another method of getting the coordinates,
but apparently there's a misunderstanding.

I'm more of a c++ guy, we'll have to to wait for a lisp expert eh

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: AutoCAD lisp to ProgeCad lisp
« Reply #5 on: February 10, 2023, 08:06:26 AM »
Try to put a "print" here to see different Output Proge/Auto CAD
Code: [Select]
...
    (setq lst (vlax-get obj 'Coordinates) idx -1 xy "")
      (print lst)  ;<<<
      (repeat (/ (length lst) 2)
        (setq xy (strcat xy (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ", "))
        (setq idx (+ 2 idx))
      )
...

kirby

  • Newt
  • Posts: 131
Re: AutoCAD lisp to ProgeCad lisp
« Reply #6 on: February 10, 2023, 10:25:06 AM »
I don't have ProgeCAD to check, but verify that ProgeCAD has exposed the 'Coordinates property, e.g. using (vlax-dump-object ...)

Code - Auto/Visual Lisp: [Select]
  1. (defun C:ListObj()
  2. ; List object methods and properties
  3. ; KJM - May 2008
  4. (setq MySel (entsel))
  5. (setq MyEnt (car MySel))
  6. (setq MyEntData (entget MyEnt))
  7. (setq EntType (strcase (cdr (assoc 0 MyEntData))))
  8.  
  9. (setq MyObj (vlax-ename->vla-object MyEnt))
  10.  
  11. ; Get object name (equivalent of AutoLisp 'type')
  12. (setq ObjType (vla-get-Objectname MyObj))
  13.  
  14. (prompt "\nEntname = ")(princ MyEnt)(prompt "  Type = ")(princ EntType)
  15. (prompt "\nObject Ref = ")(princ MyObj)(prompt "  Object Name = ")(princ ObjType)
  16.  
  17. )
  18.  

Also note that (vlax-get MyObj 'Coordinates) will return a flat list of xy pairs for LW polylines and xyz triples for heavy or 3d polylines.

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: AutoCAD lisp to ProgeCad lisp
« Reply #7 on: February 10, 2023, 05:27:13 PM »
Try this no VL

Code: [Select]
(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(princ co-ord)

Code: [Select]
;;;===================================================================;
;;; DumpIt                                                            ;
;;;-------------------------------------------------------------------;
;;; Dump all methods and properties for selected objects              ;
;;;===================================================================;
(defun C:Dumpit ( / ent)
  (while (setq ent (entsel))
    (vlax-Dump-Object
      (vlax-Ename->Vla-Object (car ent))
    )
  )
  (princ)
)
« Last Edit: February 10, 2023, 05:30:24 PM by BIGAL »
A man who never made a mistake never made anything

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: AutoCAD lisp to ProgeCad lisp
« Reply #8 on: February 13, 2023, 08:07:43 AM »

Code: [Select]
      ;----
      (setq lst (vlax-get obj 'Coordinates) idx -1 xy "")
(princ "\n lst :") (prin1 lst)   ; add this <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      (repeat (/ (length lst) 2)
        (setq xy (strcat xy (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ", "))
        (setq idx (+ 2 idx))
      )      (write-line (strcat "<LOCATION>POLYGON((" (vl-string-trim ", " xy) "))</LOCATION>") file)
      ;----

After run press F2 (textscr) and see what is value of lst

kirby

  • Newt
  • Posts: 131
Re: AutoCAD lisp to ProgeCad lisp
« Reply #9 on: February 13, 2023, 08:14:37 AM »
The "Coordinates" property may not be correctly set within ProgeCAD.  Run either the 'ListObj' I provided or 'DumpIt' that BigAL provided, it will list the available Properties and Methods.  These routines do nothing more than help use the (vlax-dump-object ...) Visual lisp function.

If you don't see "Coordinates" in the list of Properties then it isn't supported and you may have to use DXF data to get the coordinates as suggested by Ted and Marc'Antonio.

Result from ListObj and selecting a polyline...
Code - Auto/Visual Lisp: [Select]
  1. Entname = <Entity name: 1d9253224c0>  Type = POLYLINE
  2. Object Ref = #<VLA-OBJECT IAcadPolyline 000001d920d878e8>  Object Name = AcDb2dPolyline
  3. ; IAcadPolyline: AutoCAD Polyline Interface
  4. ; Property values:
  5. ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff720c65188>
  6. ;   Area (RO) = 31062.2
  7. ;   Closed = -1
  8. ;   ConstantWidth = 0.0
  9. ;   Coordinate = ...Indexed contents not shown...
  10. ;   Coordinates = (1381.39 803.853 0.0 1516.37 662.683 0.0 ... )       <------ *** Here ***
  11. ;   Document (RO) = #<VLA-OBJECT IAcadDocument 000001d925699d98>
  12. ;   Elevation = 0.0
  13. ;   EntityTransparency = "ByLayer"
  14. ;   Handle (RO) = "27C"
  15. ;   HasExtensionDictionary (RO) = 0
  16. ;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000001d920d0e3a8>
  17. ;   Layer = "0"
  18. ;   Length (RO) = 712.081
  19. ;   Linetype = "ByLayer"
  20. ;   LinetypeGeneration = 0
  21. ;   LinetypeScale = 1.0
  22. ;   Lineweight = -1
  23. ;   Material = "ByLayer"
  24. ;   Normal = (0.0 0.0 1.0)
  25. ;   ObjectID (RO) = 42
  26. ;   ObjectName (RO) = "AcDb2dPolyline"
  27. ;   OwnerID (RO) = 43
  28. ;   PlotStyleName = "ByLayer"
  29. ;   Thickness = 0.0
  30. ;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000001d920d0e040>
  31. ;   Type = 0
  32. ;   Visible = -1
  33. ; Methods supported:
  34. ;   AppendVertex (1)
  35. ;   ArrayPolar (3)
  36. ;   ArrayRectangular (6)
  37. ;   Copy ()
  38. ;   Delete ()
  39. ;   Explode ()
  40. ;   GetBoundingBox (2)
  41. ;   GetBulge (1)
  42. ;   GetExtensionDictionary ()
  43. ;   GetWidth (3)
  44. ;   GetXData (3)
  45. ;   Highlight (1)
  46. ;   IntersectWith (2)
  47. ;   Mirror (2)
  48. ;   Mirror3D (3)
  49. ;   Move (2)
  50. ;   Offset (1)
  51. ;   Rotate (2)
  52. ;   Rotate3D (3)
  53. ;   ScaleEntity (2)
  54. ;   SetBulge (2)
  55. ;   SetWidth (3)
  56. ;   SetXData (2)
  57. ;   TransformBy (1)
  58. ;   Update ()
  59.  

dexus

  • Bull Frog
  • Posts: 207
Re: CLOSED POST!!!
« Reply #10 on: February 13, 2023, 09:40:04 AM »
CLOSED POST!!!

Thank you!
Please leave your original post up just in case someone might have the same problem.
They can find this thread and be helped as well.
This way you have stopped others from befitting from this thread.

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: CLOSED POST!!!
« Reply #11 on: February 13, 2023, 09:43:04 AM »
CLOSED POST!!!

Thank you!
Please leave your original post up just in case someone might have the same problem.
They can find this thread and be helped as well.
This way you have stopped others from befitting from this thread.

*facepalm*
...If anyone remembers the original post let me know and I'll edit the post to put it back.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: CLOSED POST!!!
« Reply #12 on: February 13, 2023, 04:01:29 PM »
CLOSED POST!!!

Thank you!
Please leave your original post up just in case someone might have the same problem.
They can find this thread and be helped as well.
This way you have stopped others from befitting from this thread.


*facepalm*
...If anyone remembers the original post let me know and I'll edit the post to put it back.

John, there are some posts in "/Junk" that may be applicable. Can't make time to sift through the options at the moment.
small chance I s'pose.
looks like some replys to responses were removed too.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: CLOSED POST!!!
« Reply #13 on: February 13, 2023, 05:03:32 PM »