Jump to content

Recommended Posts

Posted

I have multiple sections which I am trying to plot using a script file. I am stuck although the format seems to match what I can find online.

 

This is what the shapes look like when I run the script file

21FBCE59-4B0F-4F61-A7BF-67ED054B1393.thumb.png.ae62b0e69c1909b6baf485444e711392.png

 

weirdly enough. the last 5 sections work just fine.

60960FA3-9759-4277-A5D9-7BC3F9C76181.thumb.png.4f0d926363f4a4e9ec1462cb3ccfd210.png

 

I know the coordinates are correct in all cases since I made a scatter plot in Excel before hand. Also, when I just copy the lines from the script file into the command line. I get the right shape every time. (Possible Clue: the command stays in pline after pasting, look at the command line)

Lines pasted into command line

_.PLINE
103150,-122340
103150,-126391.3
101272.9,-126391.3
100691.9,-125765.9
100691.9,-122965.4
101272.9,-122340
103150,-122340
C
_.PLINE
106150,-122340
106150,-126391.1
104264.2,-126391.1
103674.6,-125755.4
103674.6,-122975.7
104264.2,-122340
106150,-122340

994A9395-92EC-41E3-94DE-D45160277B8E.thumb.png.57327250c9f13309f3d3325f6593cfa8.png

{0E5027E8-CB9E-4DD5-89D1-9ADD63DA3401}.png

sections.scr

Posted

I moved your thread to the The CUI, Hatches, Linetypes, Scripts & Macros Forum.

 

Quote

the command stays in pline after pasting, look at the command line

 

Your script is missing the blank line at the bottom, so it needed that for enter at the end.

 

Other than that, I ran it in AutoCAD 2000i on my home computer and they all look like your bottom image.

  • Agree 1
Posted

Have you tried to turn off Object Snaps before you run the script?

 

It looks to me as if your line is snapping to adjacent end of line points instead of plotting the listed coordinates.

  • Thanks 1
Posted
4 hours ago, eldon said:

Have you tried to turn off Object Snaps before you run the script?

 

It looks to me as if your line is snapping to adjacent end of line points instead of plotting the listed coordinates.

Yep! That's the fix.  

Posted

Any reason why you would not use a lisp ? Very simple shape to make. Just ask. The DCL front end took 1 minute to make. Could add more shapes.

 

image.png.52b73cfa12c1c3698cb0c46d598ab3b7.png

Posted
3 minutes ago, BIGAL said:

Any reason why you would not use a lisp ? Very simple shape to make. Just ask. The DCL front end took 1 minute to make. Could add more shapes.

 

image.png.52b73cfa12c1c3698cb0c46d598ab3b7.png

I just am not that familiar with LISP commands, never used them. This is my first time where I needed many sections. Plus the geometry was defined on excel based on the contract plans. Chamfer thicknesses vary linearly.

Posted

If you have a Excel spreadsheet with the info like the DCL above, you do not need the XY points calculated as they will be calculated by the lisp. 

 

Can you post the Excel or at least an image.

 

PS can read Excel from CAD.

Posted

See the two sheets attached. First one is the dimensions, second is the one where the PLINE command is written.

PLINE Example.xlsm

Posted

You have a few choices in executing this task, you can add a macro in Excel rtaher than write a script asks for a point in your CAD, Acad or Bricscad plus others, then puts the value into your spread sheet X & Y so co-ordinates are made for the pline. Your macro than adds the pline by calling a Sub in Excel. 

 

3 pt pline for you just call the co-ords in a loop.

 Sub alan3()
 'Dim coords(0 To n) As Double
 Dim coords(0 To 5) As Double
 coords(0) = -6: coords(1) = 1:
 coords(2) = 3: coords(3) = 5:
 coords(4) = 7.55: coords(5) = 6.25:
 
 col = 1
    
 Call addpoly(coords, col)

 End Sub

 

The other way is to read the co-ords from Excel it looks like there a fixed number of rows. Can enter X & Y from cad via a pick point, then read co-ords. That seems simplest for moment as Excel is doing the calculations. 

 

I did something similar for some one else and looked at converting to all in lisp but the lookup tables were getting immense so just wrote and read Excel.

 

The only question I guess is which MS12, IB11 and so on.may be able to do a front end for that choice.

 

Will have a go at say MS12 as a start. let me know if on correct path, 

 

; https://www.cadtutor.net/forum/topic/99002-pline-script-file-keeps-failing/
; read excel draw pline
: By AlanH Feb 2026

(defun c:wow ( / myxl mysheet row lst k)

(defun getcell (cellname / )
(setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
(princ  (vlax-variant-value (vlax-get-property myRange 'Value2)))
)


; Count will be 0 if no excel open but if no workbooks also may return same value. Nil names. 
; So a double check count /=0 and wb not ""

(princ "\nOpening Excel...")

  ;; Try to get or create Excel instance
(setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application")))
  (if (vl-catch-all-error-p myxl)
    (progn
      (prompt "\nError: Could not start Excel.")
      (exit)
    )
  )
(if (=  (vlax-get-property  (vlax-get-property myXL 'WorkBooks) 'count) 0)
    (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add)
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(setq mySheet (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property myxl "Sheets") "Item" "XY Table")))

(vlax-invoke-method mySheet "Activate")

(setq row 52)
(setq lst '())
(repeat 7
(setq lst (cons (getcell (strcat "B" (rtos row 2 0))) lst))
(setq row (1+ row))
)
(setq lst (cons "C" lst))
(setq lst (reverse lst))

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq k -1)
(command "pline")
(repeat (length lst)
(command (nth (setq k (1+ k)) lst))
)
(command "Zoom" "E")

(setvar 'osmode oldsnap)

(if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil)))

(princ)
)

 

draw object xl bricscad.xlsm draw object xl acad.xlsm

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...