Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: Entlast not working
« Last post by nekonihonjin on Today at 10:58:02 AM »
Thanks for the reply domenicomaria, is like that.

gotta learn why sometimes (car (entity)) and sometimes not use car
2
This is a problem people have wanted a solution to, thanks for putting in the effort and sharing.
3
Cool stuff.
Will this shutdown loaded reactors, or is IExtensionApplication.Terminate() called for the app being unloaded?
Iím not using .net at the moment, just wondering
4
AutoLISP (Vanilla / Visual) / Re: Open Google Earth
« Last post by It's Alive! on Today at 02:59:54 AM »
MSTG007,

Where or how did you find about Google Earth within CAD? lol. Thats pretty neat.
..."Google Earth within CAD" might be a little deceptive. It's just a web page. Probably using the Javascript API!

yeah AutoCAD has a built in web browser, as you found, I used C++ function acedAddHTMLDocWindow(TITLE, URL)
surprised its not in lisp
5
AutoLISP (Vanilla / Visual) / Re: Entlast not working
« Last post by domenicomaria on Today at 01:22:00 AM »
(setq jnam2 (entlast) )
6
AutoLISP (Vanilla / Visual) / Entlast not working
« Last post by nekonihonjin on August 15, 2022, 10:30:43 PM »
Hi guys, I found in a forum this code that places points in the intersections between polylines, originally it uses this format to request the entities
Code: [Select]
(setq snam (car (entsel "\nPick ore area: "))) ;select the bigger polygon
(setq snam2 (car (entsel "\nPick starting level section: "))) ;select smaller
then
Code: [Select]
(setq sobj (vlax-ename->vla-object snam))
(setq jobj (vlax-ename->vla-object jnam))
(setq intpts (VxGetInters sobj jobj acExtendNone))

(mapcar '(lambda (l) (if (MeIsPointOnObjects l sobj jobj) (vlax-invoke (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) 'AddPoint l ) ) ) intpts );

to perfom the trick...

I want to select a polyline that has just been created with command pline and do it again but it doesn't work

Code: [Select]
(command "_pline" pivot pt1 "")
(setq jnam2 (car (entlast))); this does not match the format below?
(setq sobj2 (vlax-ename->vla-object snam2));polygon
(setq jobj2 (vlax-ename->vla-object jnam2));pline

it returns this error:
error: bad argument type: consp <Entity name: 232fd765a30>


7
AutoLISP (Vanilla / Visual) / Re: Open Google Earth
« Last post by irsm on August 15, 2022, 02:02:42 PM »
Hello CodeDing

I set camera params
and I need a coordinate of a corner of screen
can you help me
Thanks
8
AutoLISP (Vanilla / Visual) / Re: Open Google Earth
« Last post by CodeDing on August 15, 2022, 01:34:42 PM »
To maintain the integrity of OP's original question though, last year I posted a routine to do just what was requested:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:EARTH ( / *error* GeoMarker PT->LL errMsg earthPath ptMid ptLL strKML fName f)
  2. ;; Opens Google Earth. If dwg is Geo-Located, attempts to open at user-specified location.
  3.   ;; Helper Function(s)
  4.   ;; Error handler
  5.   (defun *error* (msg / )
  6.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  7.       (princ (strcat "\nError: " msg))
  8.     );if
  9.     (princ)
  10.   );error defun
  11.   (defun GeoMarker ( / ) ;; Creates arbitrary GeoMarker, returns ename
  12.     (entmakex '((0 . "POSITIONMARKER") (100 . "AcDbEntity") (100 . "AcDbGeoPositionMarker") (90 . 0) (10 0.0 0.0 0.0) (40 . 1.0)
  13.                (1 . "") (40 . 0.5) (290 . 0) (280 . 0) (290 . 1) (101 . "Embedded Object") (100 . "AcDbEntity") (100 . "AcDbMText")
  14.                (10 0.1 0.1 0.0) (40 . 1.0) (1 . "") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 9761.9) (43 . 6666.67)))
  15.   );GeoMarker defun
  16.   (defun PT->LL (pt / e luprec return) ;; Returns Longitude & Latitude of point provided
  17.     (if (setq e (GeoMarker))
  18.       (progn
  19.         (setq e (vlax-ename->vla-object e))
  20.         (vlax-put-property
  21.           e
  22.           'Position
  23.           (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 2)) pt))
  24.         );vlax
  25.         (setq luprec (getvar 'LUPREC))
  26.         (setvar 'LUPREC 8)
  27.         (setq return
  28.           (mapcar
  29.             'atof
  30.             (list (vla-get-Longitude e) (vla-get-Latitude e) "0.")
  31.           );mapcar
  32.         );setq
  33.         (setvar 'LUPREC luprec)
  34.         (vla-delete e)
  35.         return
  36.       );progn
  37.     );if
  38.   );PT->LL defun
  39.   ;; Initial checks
  40.   (cond
  41.     ((not (setq earthPath (vl-registry-read "HKEY_LOCAL_MACHINE\\SOFTWARE\\Google\\Google Earth Pro" "InstallLocation")))
  42.       (setq errMsg "\nCould not locate Google Earth application.")
  43.     );cond 1
  44.     ((not (eq "Model" (getvar 'CTAB))) (setq errMsg "\nMust be in Model space to select location."))
  45.     ((eq "" (getvar 'CGEOCS)) (setq errMsg "\nDrawing is not Geo-Located."))
  46.   );cond
  47.   (if earthPath (setq earthPath (strcat earthPath "googleearth.exe")))
  48.   ;; Open Earth now if path found and error found, or test for other error.
  49.   (cond
  50.     ((and earthPath errMsg) (startapp earthPath) (prompt errMsg) (exit))
  51.     (errMsg (prompt errMsg) (alert errMsg) (exit))
  52.   );cond
  53.   (prompt "\nPreparing to open location in Google Earth...")
  54.   ;; User-selected or arbitrary mid point of project data
  55.   (setq ptMid
  56.     (cond ((getpoint "\nSelect Point or (Enter) for default: "))
  57.           ((getvar 'VIEWCTR))
  58.     );cond
  59.   );setq
  60.   ;; Transform to Lat Long
  61.   (setq ptLL (PT->LL ptMid))
  62.   (print ptLL)
  63.   ;string for KML file
  64.   (if *earth_marker_count*
  65.     (setq *earth_marker_count* (1+ *earth_marker_count*))
  66.     (setq *earth_marker_count* 1)
  67.   );if
  68.   (setq strKML
  69.     (strcat
  70.       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  71.       "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
  72.       "  <Placemark>"
  73.       "    <name>" (getvar 'DWGNAME) " (" (itoa *earth_marker_count*) ")</name>"
  74.       "    <Point>"
  75.       "      <coordinates>" (rtos (car ptLL) 2 7) "," (rtos (cadr ptLL) 2 7) ",0</coordinates>"
  76.       "    </Point>"
  77.       "  </Placemark>"
  78.       "</kml>"
  79.     );strcat
  80.   );setq
  81.   ;; Write string to KML file
  82.   (setq fName (vl-filename-mktemp "C3D" nil ".kml"))
  83.   (write-line strKML (setq f (open fName "w")))
  84.   (close f)
  85.   ;; Open KML in Google Earth
  86.   (startapp earthPath fName)
  87.   (prompt "\nEARTH Complete.")
  88.   (princ)
  89. );defun
  90.  

Sauce:
https://forums.autodesk.com/t5/civil-3d-customization/google-earth-command-in-autocad/td-p/10598071

Best,
~DD
9
AutoLISP (Vanilla / Visual) / Re: Open Google Earth
« Last post by CodeDing on August 15, 2022, 01:26:50 PM »
MSTG007,

Where or how did you find about Google Earth within CAD? lol. Thats pretty neat.
..."Google Earth within CAD" might be a little deceptive. It's just a web page. Probably using the Javascript API!

Source:
https://help.autodesk.com/view/OARX/2022/ENU/?guid=adsk_jsdev_autocad_javascript_api_about

To Test:
Save this as html document..
Code: [Select]
<html>
   <head>
       <title>Some Title</title>
       <script type="text/javascript" src="https://df-prod.autocad360.com/jsapi/v3/Autodesk.AutoCAD.js ">
       </script>
       <script type="text/javascript">

           function myFunction() {
             Acad.Application.addDocWindow("Another Title", "https://www.theswamp.org/index.php?topic=54086.msg611080#msg611080");
           }

           myFunction();

       </script>
   </head>

   <body>

   </body>
</html>

...then run code to execute your html...
Code: [Select]
(command "_.WEBLOAD" "l" "c:\\users\\me\\desktop\\myWebDocument.html")
Best,
~DD
10
AutoLISP (Vanilla / Visual) / Re: Select objects inside 3D solid
« Last post by nekonihonjin on August 15, 2022, 11:14:22 AM »
Thanks for the answers Scott, that's a good starting point, I'm going to approach it that way.

The coordinates are not necessary for the ultimate goal, I have a lisp that generates a table where it lists the attributes of the selected objects and calculates the weighted average of each of the elements.
To be able to say, this zone that represents the solid is, for example, 857m3 with an average value of x x x x x x. It is only necessary to have the elements in selection, filtered of those that remain outside the solid, to apply to that selection the lisp that generates the table.
Pages: [1] 2 3 ... 10