Jump to content

Cad and Excel


ddoc

Recommended Posts

Hi,

 

I am looking for some info\tutorials on how I would create a dxf from data in an excel spreadsheet?

 

I have a spreadsheet that calculates data for steel portal frames, within the spreadsheet I have an area of cells that contain x y z data in decimal form.

 

I had found an excel plugin called dxfert that allows me to select these cells and the cell data is duly converted to a dxf however, the plugin is limited in that it will only output a continuous polyline.

 

I am hoping someone can point me in the right direction to what I need to learn to allow me to output these points as a complete drawing?

 

Kind regards

 

Dave.

Link to comment
Share on other sites

Forget dxf just go straight to a script and write autocad commands, here is the simplest example points from x y z excel. Steven-G an example ?

 

point 12,34,0
point 56,78,0
point 99,78,0

note blank line at end to signify end of a command =

PLINE
12,34
45.67
78,89

line
123,456
789,123
45,67

[/code]

Link to comment
Share on other sites

BIGAL,

 

Many thanks for the info, I've now started to implement your advice into my spreadsheet, hopefully it will be enough to create the drawings and I won't have to learn programming - as much as I would like to learn, I don't really have enough time however, your advice will get me closer to where I need to be.

 

I have another question though!

 

I found another post of yours which I found very helpful using Concatenate, my spreadsheet now looks like this:

 

Slab		           x	        y	          z				
Start	           0	           0	        0		line		        line 0,0
Low Right	24000	   0	        0		line		        line 24000,0
High Right	24000      20000	        0		line		        line 24000,20000
High Left	   0	       20000	        0		line		        line 0,20000
Home	   0	           0	        0		line		        line 0,0
Grid X								
Start	         305	       -1000	        0		centerx2		centerx2 304.9,-1000
	         305	       21000	        0		centerx2		centerx2 304.9,21000

 

My problem is centerx2 all the items with line draw as expected however centerx2 does not draw, it only draws if I rename it to line.

 

How do I get it to draw a centerline or where would i find this information? also is there a way to easily include line colour and\or separate layers?

 

Apologies for the formating in the code box!

Thanks

 

Kind regards

 

Dave.

Edited by ddoc
Further problems
Link to comment
Share on other sites

A couple of ways this is the simplest if by layer and layer exists, I suggest add all your layers at start. Also not sure of above but you do not repeat the LINE each row, only need co-ords.

 

this saves an extra line which may stuff up your excel rowscolumns 
-layer s "layer2" line 0,0
24000,2000
0,2000

-layer s "layer3" line 304.9,-1000
600,-1000
etc

Link to comment
Share on other sites

Just a couple of additions, using

-ltype s centerx2
line 304.9,-1000

will allow you to set the new linetype without it being previously loaded,

and it can also be used transparently so you can swap linetypes in the middle of the script, but as BIGAL mentioned, it will mess up your excel rows, because it needs at least 2 rows (any time you use a name it has to be at the end of a line for the script to work, and note that the following line starts with a space to cancel the ltype command)

Link to comment
Share on other sites

Many thanks for your replies, very helpful.

 

I have so far managed to draw the floor slab and grid - grid drawn in centerx2 - from the advice you have both provided.

 

The following screenshot might help explain why I have line in every row - I found a post by BIGAL that showed how to concatenate points albeit I used it for lines.

 

From the screenshot you will note i opted for Steven-G's option as creating a new linetype suits what I am trying to do.

 

Rows 9 - 14 are my attempt at adding a new layer, giving it a name and giving it a colour however, this is not working how I would like it - the best I can get it to do is open the layer applet and the colour applet, where I have to manually select a colour three times and manually create a new layer.

 

Is it possible to automate a new layer giving colour and a name?

 

As I am only just starting out with this spreadsheet, having to add in additional rows is not currently a problem, my spreadsheet contains only 56 rows including spaces. I am really happy at having the grid drawn, just looking to learn how to format it automatically.

 

Untitled picture.jpg

Link to comment
Share on other sites

  • 3 months later...

Hi, still trying to refine this further though, I have made some changes but still not understanding why it is not doing what I want it to do, perhaps someone could hopefully help me out?

 

Okay

 

Screenshot 1 shows my script for drawing lines

Screenshot 1.jpg

 

This gives me the result I am looking for as in the next screenshot

Screenshot 2.jpg

 

Now I have found that to add circles, I have to have a second script file - having a second script was the only way to be able to get the circles to show up this is shown in the next screenshot

Screenshot 3.jpg

 

The first 9 lines of this script places circles on the lowest part of the second screenshot as per the next screenshot

Screenshot 4.jpg

 

The remaining two lines should place circles on the next item up on the above screenshot, however, it does not.

 

Appreciate if someone could explain what I need to do to get this to work please?

 

The script files are copied from excel cells and pasted into Notepad.

Screenshot 5.jpg

 

Kind regards

 

Dave.

Link to comment
Share on other sites

What do you see on the command line ?

My first thought would be that the blank line after the first set of circles actually causes Autocad to start the circle command again, and it expects the coordinates but the following line starts with the word circle, causing an error.

Link to comment
Share on other sites

Thanks for your response Steven.

 

The following is from the command line and does indeed ask for a point or option keyword

 

Command: SCRIPT

Command: circle

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 35,46

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 35,106

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 1073,120

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 1133,120

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 2168,58

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 2168,118

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 2118,58

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 2118,118

Specify radius of circle or [Diameter] : 9

Command: CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 1938,118

Specify radius of circle or [Diameter] : 9

Command:

CIRCLE

Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:

Point or option keyword required.

 

I have changed the formula in excel to not reference the word circle where you point out and this works to a fashion in that it only shows 1 circle.

 

 

Thanks Steven, with your advice I have figured it out, the second circle is now showing using the following

 

Screenshot 6.jpg

Link to comment
Share on other sites

See your other post, re layers type -layer and look at the prompts -layer n abcde c 1 abcde lt center2 abcde you have to imply which layer is using what.

 

Ps your beams drew ok in other post.

Link to comment
Share on other sites

  • 3 months later...

Hi, back again!

 

Okay, I have had to revise my script to include all commands as opposed to having separate script files for each comand.

 

My problem now is how to terminate the circle command whereby it is ready to start the next line command.

 

My script starts thus:

 

line 0,0

2358,0

2358,152

2358,152

2358,152

0,152

0,0

0,20

2358,20

2358,132

0,132

 

0,500

2358,500

2358,500

2358,500

2358,564

0,564

0,500

 

0,-348

2358,-348

2358,-348

2358,-348

2358,-412

0,-412

0,-348

0,-348

 

_dimlinear 0,152 2358,152 @0,202

_dimlinear 0,152 35,106 @0,152

_dimlinear 35,106 1073,106 @35,152

_dimlinear 1073,106 1133,106 @1073,152

_dimlinear 1133,106 2090,106 @1133,152

_dimlinear 2090,106 2270,106 @2090,152

_dimlinear 2270,106 2320,106 @2270,152

_dimlinear 35,106 0,152 v @-100,152

_dimlinear 35,46 0,0 v @-100,152

_dimlinear 1073,118 1073,152 v @-100,152

_dimlinear 2090,118 2090,152 v @-100,152

_dimlinear 2320,58 2320,0 v @100,152

_dimlinear 0,-380 2358,-380 @1073,202

_dimlinear 0,-500 0,-500 @0,-500

_dimlinear 0,-500 0,-500 @0,-500

_dimlinear 0,-380 1073,-380 @0,114

_dimlinear 1073,-380 1133,-380 @0,114

_dimlinear , , @,

_dimlinear 1073,-380 1073,-380 @1073,-380

_dimlinear 1073,-380 0,-380 @2358,-898

_dimlinear 2090,-380 2270,-380 @0,114

_dimlinear 2270,-380 2320,-380 @0,114

_dimlinear 1073,-380 1073,-348 v @-100,152

_text 0,-662 25 0 C150 Corner Column Front Left

circle 35,46 9

35,106 9

1073,118 9

0,-500 9

0,-500 9

1133,118 9

2320,58 9

2320,118 9

2270,58 9

2270,118 9

2090,118 9

1073,-380 9

1133,-380 9

0,-500 9

0,-500 9

2320,-380 9

2270,-380 9

2090,-380 9

;one space in last line above

 

line 0,2000

2358,2000

2358,2152

2358,2152

2358,2152

0,2152

0,2000

0,2020

2358,2020

2358,2132

0,2132

 

I have highlighted in red above the end of the circle command having two spaces to terminate the command however, this results in the command line requesting\wanting to draw another circle when it should be moving on to the next line command.

 

I have tried removing the two spaces, replacing with one then two new blank lines but no matter what I've tried Autocad 2016 always is looking for the next circle.

 

How do I write the script to make it move on to the next line command?

 

Appreciate your input

 

Dave

Link to comment
Share on other sites

Hi BIGAL, many thanks for your reply, following your advice I have got it working by changing my script to the following:

 

_dimlinear 2270,-380 2320,-380 @0,114

_dimlinear 1073,-380 1073,-348 v @-100,152

_text 0,-662 25 0 C150 Corner Column Front Left

circle 35,46 9

35,106 9

1073,118 9

0,-500 9

0,-500 9

1133,118 9

2320,58 9

2320,118 9

2270,58 9

2270,118 9

2090,118 9

1073,-380 9

1133,-380 9

0,-500 9

0,-500 9

2320,-380 9

2270,-380 9

2090,-380 9

;no space in last line above

line 0,2000

2358,2000

2358,2152

2358,2152

2358,2152

0,2152

 

I am really happy with my script now, again, many thanks for your help on this matter I really do appreciate it.

 

Kind regards

 

Dave.

Link to comment
Share on other sites

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...