Excel vers autocad

totoeole Messages postés 1 Date d'inscription mercredi 8 mars 2006 Statut Membre Dernière intervention 9 mars 2006 - 9 mars 2006 à 16:00
radinor Messages postés 12 Date d'inscription mercredi 11 mars 2009 Statut Membre Dernière intervention 24 octobre 2011 - 25 mai 2009 à 22:40
Je veux, à partir d'un fichier excel contenant des coordonnées en x, y
et z, tracé une courbe dans autocad par le biais d'une macro en vba.

J'ai fait la macro suivante pour faire un essai avec une ligne :




Sub essai()



Dim Line As AcadLine

Dim A(0 To 2) As Double, B(0 To 2) As Double

Dim AutoCAD As Object



Set AutoCAD = CreateObject("Autocad.Application")



A(0) 0: A(1) 1: A(2) = 0

B(0) 0: B(0) 1: B(2) = 0



AutoCAD.Documents.Add



Set Line = AutoCAD.ThisDrawing.Application.ActiveDocument.ModelSpace.AddLine(A, B)



AutoCAD.ThisDrawing.AcadApplication.ZoomExtents





AutoCAD.ActiveDocument.SaveAs "C:\Documents and Settings\LBO\Bureau\toto.dwg"



AutoCAD.ActiveDocument.Close



Set AutoCAD = Nothing



End Sub



Autocad démarre bien mais il ne veut pas comprendre la ligne "set line ...."



Je suis hyper débutant en vba et si quelqu'un peut m'aider ....



merci d'avance !

5 réponses

OM232721 Messages postés 3 Date d'inscription lundi 22 janvier 2007 Statut Membre Dernière intervention 25 janvier 2007
24 janv. 2007 à 12:07
Je suis débutant également, j'ai eu le même problemme que toi .
Pour dessiner les point sans faire de grosse programmation :
insicri par macro les commades que tu saisie dans Autocad dans une feuille Excel
Enregistre cette feuille en fichier texte
Sorts d'excel
Renomme cette feuille en .scr
Fait glisser le fichier sur Autocad
Oh Magie, Tout ce dessine !!

exemple du fichier :
Clayer "0"
Point 260.903829555595,277.288490076819,0
Point 266.085040539351,277.904933512056,0
Point 272.463487763156,278.415988959215,0
Point 281.33122467676,278.67660354469,0
Point 291.29052425546,278.347805778309,0
Point 297.136991224307,277.84708930556,0
Point 305.057143392157,276.800961415365,0
Point 314.702740040901,274.942786638045,0
Point 318.007485605102,274.154710448377,0
Point 326.848433521114,271.652847136647,0
Point 337.385232510158,267.886837949089,0
Point 347.662914345643,263.327082182645,0
Point 354.260660213788,259.896990180323,0
Point 362.995014920948,255.554997989636,0
Point 370.55865797229,251.442153644489,0
Point 377.38029304926,248.576438033475,0
Point 385.030722387914,246.729642800736,0
Point 392.043617331031,245.583356841146,0
Point 397.781440466308,245.201260809242,0
Point 403.838031553546,245.455991259831,0
Point 407.727000265779,245.774404501078,0
Point 265.953098552873,277.16361624223,0
Point 271.125787936651,277.585962989317,0
Point 277.479841987541,277.928746518321,0
Point 286.308667693731,277.910841193503,0
Point 296.209906193852,277.203313717112,0
Point 302.007710640585,276.542224448572,0
Point 309.85315712586,275.264872535176,0
Point 319.367581645391,273.066420902838,0
Point 322.64866121007,272.193151505504,0
Point 331.354425856777,269.403988560916,0
Point 342.199398181633,266.408615804037,0
Point 352.383480412485,261.567633354796,0
Point 358.469029344221,257.130303290216,0
Point 367.71050278892,253.761294660954,0
Point 375.494530545762,250.293341468045,0
Point 382.398886194498,248.061225816216,0
Point 390.08199800718,246.649289819907,0
Point 397.083891279289,246.102137981817,0
Point 273.330738671189,279.11416151987,0
Point 278.546208786244,279.267439362383,0
Point 284.983605474176,279.19004881004,0
Point 293.87093278288,278.733845771761,0
Point 303.80330948698,277.644807778001,0
Point 309.61350056279,276.579009112062,0
Point 317.449032431304,274.909666258724,0
Point 326.946460239222,272.305496154022,0
Point 330.183575886425,271.127384789712,0
Point 338.83129182702,267.906959998029,0
Point 348.500454870631,262.209977276302,0
Point 358.519494027558,257.087188966988,0
Point 365.698863052903,254.776287424192,0
Point 373.904375022214,249.326541537387,0
Point 382.196113363958,246.621534305092,0
Point 389.502364620772,245.33536661739,0
Point 397.394508348351,244.545126090447,0
Point 404.606278061898,244.746063085592,0
Point 0.672394541782356,0,0
Point 263.523109219323,278.277260197614,0
Point 269.920863713416,278.847979218052,0
Point 278.814537070222,279.20772467886,0
Point 288.814071727118,279.102324617417,0
Point 294.701060694883,278.702036211959,0
Point 302.657870207792,277.727944028456,0
Point 312.371720433557,276.058563474193,0
Point 315.721273898879,275.345179511135,0
Point 324.607587404696,272.915549105361,0
Point 334.827519087025,268.158708816291,0
Point 345.126182350434,263.773964850557,0
Point 352.322758653966,261.589219287766,0
Point 360.464942080945,256.08162654289,0
Point 367.994406340618,251.959742172621,0
Point 374.821853574224,248.94111596425,0
Point 382.440866853723,246.654889589263,0
Point 389.452107227005,245.226476265323,0
_dimaligned 265.867971770963,277.87910738421,0 265.953098552873,277.16361624223,0 265.867971770963,277.87910738421,0
_dimaligned 273.350491196363,278.442057169662,0 273.330738671189,279.11416151987,0 273.350491196363,278.442057169662,0
0
Rejoignez-nous