• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

draw a polyline from excel values

  • Thread starter Thread starter xsky998
  • Start date Start date
:4404:

:hahahah: joke from... in the previous post I wrote that I found the macro and read the code inside.... (the one in the button :finger:). .

and the macro first generates the dxf file (which at the end is a text file) and then opens it with autocad (shellexecute 0, vbnullstring, nprofile, vbnullstring, "", 1)

then to edit or add qlc you have to do so by inserting the dxf code on the objects to be added within the file.
That's right!
I do not know whether the time spent by the publication of this 3d now warrants my intervention. I hope I'm not bored.

The author of that file is me.
the file arises from a specific request by a student who had the need to draw the diagrams of the bending moments (usually parabolic form) and of the cut in autocad but taking the data from the elaborations that it still performed with the help of excel. think, for example, the resolution of a beam continues to support. I simply adapted part of the code written for other purpose (drawing of metal profiles with data obtained from excel).
In fact, the code writes a file type *.dxf containing the only information about polylines and is then opened in autocad.
try to change the code by providing you with the possibility to insert texts, formatting texts, styles, layers, colors and other would be quite laborious.
I published the file in free form with code readable by everyone, so no problem if someone took it and changed it.

greetings
 
I am not a dxf expert to add quotas you need to know how acad writes a quota in dxf and then change the vba. Sincerely it takes a little time and it is not precisely the direction in which I would like to use mine.

I added as required a column to the previous file, the thing is trivial and if they can add as many as they want.

inside the vba I added three rows in the select case, I commented them so they are easily identifiable.

If you want to add the seventh column inside the excel sheet, you need to copy and paste the three reference columns.

then it is necessary to define the following variables:

n_7 indicating the number of points that would be found in ac11
c_7 in aa14
tab_7 defined within the variable definition form and equal to: =carto(c_7;0;n_7;3)

you need to change the cell u8 and also add the presence of the new column.

Incidentally, I normally prefer to write to the vba, rather than a dxf a autocad script, which later is more easily editable. It is also easier to enter complex commands. question of tastes!

wave
You understand the code perfectly.
 
Even if I'm late, but now I can thank you:finger:, both for the original file you produced and both because you encouraged me to study the subject so much that now I program more than discreetly both with vba and vb.net. See you soon! !
 
Write the excel sequence as it appears in the autocad command line, paste it into the autocad command line
 
I am not a dxf expert to add quotas you need to know how acad writes a quota in dxf and then change the vba. Sincerely it takes a little time and it is not precisely the direction in which I would like to use mine.

I added as required a column to the previous file, the thing is trivial and if they can add as many as they want.

inside the vba I added three rows in the select case, I commented them so they are easily identifiable.

If you want to add the seventh column inside the excel sheet, you need to copy and paste the three reference columns.

then it is necessary to define the following variables:

n_7 indicating the number of points that would be found in ac11
c_7 in aa14
tab_7 defined within the variable definition form and equal to: =carto(c_7;0;n_7;3)

you need to change the cell u8 and also add the presence of the new column.

Incidentally, I normally prefer to write to the vba, rather than a dxf a autocad script, which later is more easily editable. It is also easier to enter complex commands. question of tastes!

wave
hello to all boys, I press that I am new to the forum and above all I am also novice of vba.
I have a wave question.
First of all, it's helping me a lot of your modification to the original file.
My only doubt (which arises from the fact that we always have a minimum of 32 in the seismic zone) is in the table statement.
I managed to define c_7 and n_7, but tab_7 and the change of cell u8 did not go well, could you help me by sending me the code?
 
You don't know how much time I saved thanks to this code, you saved me. Thank you so much! :
 
if you want to understand how to do it independently then follow the instructions:

three different names must be attributed:

the name n_xx to the yellow cells. here is the number of points in the relative table
c_xx name to the first cell of each table (the cell where the number 1) is reported. this serves to establish the starting point of the dynamic table
the tab_xx name at each table. but the table must be dynamic and therefore must be defined by the command "formule"-->"name management". the name must be defined by the formula "=scarto(c_xx;0;0;n_xx;3)".
of course "xx" indicates the sequential number of tables.

Finally, you have to make a slight change in the code to predict even the cases of a larger number of tables:

select houses
houses 1
number_r = range(n_1).value
coordinates = range("tab_1")
houses 2
number_r = range(n_2).value
coordinates = range("tab_2")
...
...
...

houses 31
number_r = range(n_31).value
coordinates = range("tab_31")
32 houses
number_r = range(n_32).value
coordinates = range("tab_32")

homes else
msgbox " error in the number of diagrams to draw"
exit sub
end select

Hi.
 
suggerimento:
select case conta_poly
case 1
numero_r = range("n_1").value
coordinate = range("tab_1")
....
end select

puoi trasformarlo in

select case conta_poly
case 1 to 32
numero_r = range("n_" & conta_poly).value
coordinate = range("tab_" & conta_poly)
end select

per utilizzare il software anche con office x64 includi queste righe:
#if vba7 then
private declare ptrsafe function shellexecute lib "shell32.dll" alias "shellexecutea" (byval hwnd as long, byval lpoperation as string, byval lpfile as string, byval lpparameters as string, byval lpdirectory as string, byval nshowcmd as long) as long
#else
private declare function shellexecute lib "shell32.dll" alias "shellexecutea" (byval hwnd as long, byval lpoperation as string, byval lpfile as string, byval lpparameters as string, byval lpdirectory as string, byval nshowcmd as long) as long
#end if

bye
 
thanks rpor66
a suggestion that saves many lines.

the rows to run the code also for office x64, the rows you reported replace the only now present about the shell call?
 
Okay, I replaced them.
it happens that the first of the two rows is recognized as vba error for excel x32, and then highlighted in red (it does not recognize the word prtsafe) but performing it code does not go wrong.
Thanks again.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top