|
drawing line with programming
hi......i'm new in solidwork...............i have to do programming with vba in solid work for my final year project......let say i want to draw line with 5 cm......when i run my programming the line will show in solidwork........can someone hlp me how to do this......i'm really appreciate for the help.....
dim swapp as object
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.createline(0#, 0#, 0#, 0.05, 0#, 0#)
end sub
part.sketchmanager.createline(0#, 0#, 0#, 0.05, 0#, 0#)
an error occured in this line.......
try removing the brackets. so it should be like this
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
cheers,
--stav.
in this world i am nobody...
and nobody is perfect ;) !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
i have tried.......when i run it say object variable or with block variable not set.........i've just copy the codding and paste it to code........if i miss the important part..........
1. select a plane
2. start a sketch
3. start recording a macro
4. draw a line
5. dimension it 5mm
6. stop recording the macro
7. edit the macro to see the code
cad monkey
sw2k7 sp5.0
sw2k8 sp3.0
edited: 08/08/2008 at 09:07 am by dan eldred
dim swapp as sldworks.sldworks
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.insertsketch true
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
end sub
i have applied the to record the lines and modified the codding, so when i put 5mm in my program the lines will appear..................but the problem is the program can communicate with the file that it record......how to build a program so that it can communicate with any files in solid work.........
dim swapp as sldworks.sldworks
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.insertsketch true
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
end sub
tq luke............this code is usefull.........
i a confuse with this code
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
this code means that the line will create in horizontal........where should i change the value so that the line will create vertical.....
and finally i want to operate it to become the rectangular.........
hi zam
have a look in the solidworks api help every function is documented:
syntax (ole automation)
retval = sketchmanager.createline ( x1, y1, z1, x2, y2, z2)
input:
(double) x1
x coordinate of the line start point
input:
(double) y1
y coordinate of the line start point
input:
(double) z1
z coordinate of the line start point
input:
(double) x2
x coordinate of the line end point
input:
(double) y2
y coordinate of the line end point
input:
(double) z2
z coordinate of the line end point
output:
(lpsketchsegment) retval
sketch segment for the line
if you want a rectangle call the function four times with the appropraite values.
regards
tom mulder.
compac nw8440
intel core 2 t7400 2.16ghz
ati mobility firegl v5200
solidworks 2008 sp4.0
windows xp professional sp2
ps. if you run functions as a macro you will need to omit the brackets
regards
tom mulder.
compac nw8440
intel core 2 t7400 2.16ghz
ati mobility firegl v5200
solidworks 2008 sp4.0
windows xp professional sp2 |
|