All Activity
- Past hour
-
Danielm103 started following Excel link - Sanity check please
-
Excel link - Sanity check please
Danielm103 replied to swanny89's topic in AutoLISP, Visual LISP & DCL
I have an app on the store, XLSX Field Evaluator https://apps.autodesk.com/ACD/en/Detail/Index?id=4867035866745163447&appLang=en&os=Win64 You can add fields to block attributes that are linked to excel There’s trial version https://apps.autodesk.com/ACD/en/Detail/Index?id=4446191126131749248&appLang=en&os=Win64 it never expires, capped at 20 fields though - Today
-
Excel link - Sanity check please
swanny89 replied to swanny89's topic in AutoLISP, Visual LISP & DCL
@Lee Mac Ok fantastic that's great news thank you. The problem is that this data will ALWAYS be held and monitored in an excel spreadsheet. The company uses this method as a standard and it will never change, I'm trying to gather the data without changing any procedures as this would invoke carnage. I've got the code to read from and write to the blocks working fine. As the next step, I'm trying to simply read a cell value from Excel, but it keeps throwing "error: bad argument type: VLA-OBJECT nil" and I don't have the experience to figure out why (I'm new to LISP). This is the code I have. Are you able to give me a nudge in the right direction? Or provide some sample code that will let me read a cell value? Many thanks; (defun c:FindExcelValue ( / fname xlApp xlBook xlSheet searchStr foundVal row col cellVal) ;; Prompt for Excel file path (setq fname (getfiled "Select Excel file" "" "xls;xlsx" 0)) (if fname (progn ;; Ask for search string (setq searchStr (getstring T "\nEnter string to search for: ")) ;; Start Excel (setq xlApp (vlax-get-or-create-object "Excel.Application")) (setq xlBook (vlax-invoke-method (vlax-get-property xlApp 'Workbooks) 'Open fname)) (setq xlSheet (vlax-get-property xlBook 'ActiveSheet)) ;; Assume search in column A (col = 1) (setq row 1 col 1 foundVal nil) ;; Loop until empty cell (while (and (not foundVal) (setq cellVal (vlax-get-property (vlax-get-property xlSheet 'Cells) 'Item row col)) (/= (vlax-get-property cellVal 'Value) nil)) (if (= (strcase (vlax-get-property cellVal 'Value)) (strcase searchStr)) (setq foundVal (vlax-get-property (vlax-get-property xlSheet 'Cells) 'Item row (1+ col)) 'Value)) (setq row (1+ row)) ) ;; Print result (if foundVal (princ (strcat "\nFound value: " (vl-princ-to-string foundVal))) (princ "\nString not found.") ) ;; Clean up (vlax-invoke-method xlBook 'Close :vlax-false) (vlax-release-object xlSheet) (vlax-release-object xlBook) (vlax-release-object xlApp) ) ) (princ) ) -
Lee Mac started following Excel link - Sanity check please
-
Yes, this is possible; though, you'll find it easier using a .csv/.txt file (which can be read using standard AutoLISP IO functions), in lieu of an .xls/.xlsx file (for which you'll need to use ActiveX(COM) to interface with the installed Excel application). Once the data has been acquired however, updating the block attributes is straightforward.
-
Hi all, I have an idea for an AutoCAD lisp, but I don't know if it's possible. I'd like to get a sanity check before I attempt creating it! The process I'm thinking of is as follows; 1. Iterate through a number of blocks in the .dwg (blocks are always in model space) 2. For each block grab an attribute value held within the block (FIN-B / FIN-C) in the example dwg - This data will be entered manually for each block 3. Search for this "value" in an external excel file (prompt user to pick a file) - The value will always be in Column A 4. Copy the information held in the three relevant cells (Column B - the the same row and the next two rows below) back into the block (FIN-LINE-1 / 2 / 3) 5. Repeat this process until all named blocks are populated (theExcel.xlsxre are 10 blocks maximum) I don't mind if I have to change the formatting a little etc. But I'd just like to know if this would actually be possible or if I will hit a barrier that will prevent it from working. Could anyone please tell me if this is possible or would it be a waste of time to try? I've attached an example .dwg and excel file for reference. Thank you in advance for any help. Cad Blocks.dwg
-
Copy and paste error (blocks changes!)
X11start replied to X11start's topic in AutoLISP, Visual LISP & DCL
... I didn't tell you that I use GStarCAD: this would be one of the very rare cases where an AutoCAD lisp is not compatible with GStarCAD! I need to try it on a co-worker PC: they use AutoCAD LT (which should now make the lisps work... let's hope also the VL-XXX ones!). Anyway, thank you for your availability. -
Please help me if you know about lisp. Thank you.
CAD2005 replied to CAD2005's topic in AutoLISP, Visual LISP & DCL
Thank you very much @Nikon! Thank you. -
Please help me if you know about lisp. Thank you.
CAD2005 replied to CAD2005's topic in AutoLISP, Visual LISP & DCL
@ -
Please help me if you know about lisp. Thank you.
CAD2005 replied to CAD2005's topic in AutoLISP, Visual LISP & DCL
- Yesterday
-
bustr started following Verify attribute values?
-
Does anyone know how to turn off the setting that prompts to "Verify attribute values"? I am trying to run a script.
-
Select both polylines find the polyline that has the most vertex Then process those vertex with vlax-curve-getClosestPointTo store the mid point of vertex and closest point in a list entmake new polyline with list points. Seems to work well tho will need to test if you have open or closed polylines. defaults to closed tho i don't think its quite the mid / avg path ;;----------------------------------------------------------------------------;; ;; CLOSE POLY AVERAGE, Finds the mid point avg between close polylines donut shape (defun c:CLOSEPOLYAVG (/ sel1 sel2 ent1 ent2 cnt1 cnt2 main other i ptv ptc mid pts) (defun c:CPA () (C:CLOSEPOLYAVG)) (defun midpt (p1 p2) (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2) ) (setq sel1 (entsel "\nSelect First close Polyline: ")) (setq sel2 (entsel "\nSelect Second closed Polyline: ")) (if (and sel1 sel2) (progn (setq ent1 (vlax-ename->vla-object (car sel1)) ent2 (vlax-ename->vla-object (car sel2)) cnt1 (fix (vlax-curve-getEndParam ent1)) cnt2 (fix (vlax-curve-getEndParam ent2)) ) (if (> cnt1 cnt2) (setq main ent1 other ent2) (setq main ent2 other ent1) ) (setq pts '()) (setq i 0) (while (<= i (fix (vlax-curve-getEndParam main))) (setq ptv (vlax-curve-getPointAtParam main i)) (setq ptc (vlax-curve-getClosestPointTo other ptv)) (setq mid (midpt ptv ptc)) (setq pts (append pts (list mid))) (setq i (1+ i)) ) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pts)) '(70 . 1) ;; closed ) (mapcar '(lambda (p) (cons 10 p)) pts) ) ) (princ "\nNew midpoint polyline created.") ) (princ "\nSelection error.") ) (princ) )
-
@pkenewell Thank you very much. I finally got it working. In my case, I set the "length of arcs" to 1. And it worked. But I think the resulting axis isn't very geometrically rigorous. I've attached an example image: -The polyline created by the command is shown in green. -The correct geometry of the axis is shown in dashed red. I think there should be a more geometrically rigorous solution in some older Lisp. Is it possible? Does anyone know of one?
-
ediazg joined the community
-
Finding (and detaching) Raster Image and PDF references in AutoLISP
Jabberwocky replied to Jabberwocky's topic in AutoLISP, Visual LISP & DCL
That did exactly what I needed. Thanks so much! -
The "MC" command by roy437 works for me on your example drawing. You have to set the point resolution (prompt for "Specify Length for arc(ds)") to improve the results. I used 0.1 for pretty good results.
-
The code does not work correctly with polylines that have a large number of segments. Example1.dwg
-
I attach an example Example.dwg
-
@pkenewell Thanks for help. I downloaded the latest code from link and loaded it, but it doesn't seem to do anything. I probably don't understand how it works.
-
@NikonThanks for the code. I tried it. But it only works sometimes. And if the polylines' first point coincides with the last, it doesn't work. Is it possible that I'm doing something wrong?
-
popzz joined the community
-
I can run drafixcad v2.1 with emulator otvdm ( winevdm)16bit installed in windows 11 x64 found on github https://github.com/otya128/winevdm?tab=readme-ov-file Regards Pop
-
-
pkenewell started following Hybrid parallel
-
Look into this post for ideas:
-
Yes you can use the plain ROTATE commad uing the reference option. For example, Command: ROTATE Current positive angle in UCS: ANGDIR=counterclockwise ANGBASE=0 Select objects: 1 found Select objects: pick object then enter Specify base point: vertex 1 Specify rotation angle or [Copy/Reference] <0>: r Specify the reference angle <0>: vertex 1 again Specify second point: vertex 2 Specify the new angle or [Points] <0>: vertex 3
-
Perhaps the most appropriate description is to obtain the axis between 2 irregular polylines
-
Please help me if you know about lisp. Thank you.
Nikon replied to CAD2005's topic in AutoLISP, Visual LISP & DCL
You can also watch here: https://forums.augi.com/showthread.php?53180-Change-color-of-existing-MTEXT-Objects&highlight=remove formating -
sdffd joined the community
-
Dahzee started following Pyramid rotation
-
I'm no 3D expert, but should the OP be using the 2D Rotate if all they are doing is copying the Pyramid onto its side?