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

problems with macro in selection and realization of fittings in a solidworks model

OSCAR$

Guest
Good morning to all,
I made a series of elements, 32, on a plate and I need to collect them in the contact area with this.
to do this I made a simple macro, as the number of elements can be variable and I used a cycle for.
not all fittings are made, but only 6.
the edges to be connected are selected by the command selectbyid2, as I know their coordinates and I think it is the only available function that uses this method, for me necessary.
searching on the net I found that the method of selection has "problems", the image must be sufficiently zoomed and understand all the elements to be connected, which I did.
I tried to use the function Featurefillet3 inside and outside the for cycle, in the first case the macro creates only the first 6, while in the second it combines some elements.
raggio variabile - Copia.webpraggio variabile - Copia.webp

di seguito il programma in vba, sto usando solidworks 2015.

option explicit
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
dim swmodview as sldworks.modelview

sub main()

set swapp = application.sldworks

set part = swapp.activedoc
set swmodview = part.activeview
dim passo, i as double
dim delta_y, x_0, z as double
x_0 = 159.26 / 1000
z = -1 / 1000
dim x_angle, y_angle as double
x_angle = -45
y_angle = 0

for i = 0 to 7
passo = (3.16 / 1000)
delta_y = (-5.5 / 1000) + (i * passo)
boolstatus = part.extension.selectbyid2("", "edge", x_0, delta_y, z, true, 1, nothing, 0)
next

dim radiiarray0 as variant
dim radiis0 as double
dim dist2array0 as variant
dim dists20 as double
dim conicrhosarray0 as variant
dim conirhos0 as double
dim setbackarray0 as variant
dim setbacks0 as double
dim pointarray0 as variant
dim points0 as double
dim pointdist2array0 as variant
dim pointsdist20 as double
dim pointrhoarray0 as variant
dim pointsrhos0 as double
radiiarray0 = radiis0
dist2array0 = dists20
conicrhosarray0 = conirhos0
setbackarray0 = setbacks0
pointarray0 = points0
pointdist2array0 = pointsdist20
pointrhoarray0 = pointsrhos0
dim myfeature as sldworks.feature
set myfeature = part.featuremanager.featurefillet3(195, 0.001, 0#, 0, 0, 0, 0, (radiiarray0), (dist2array0), (conicrhosarray0), (setbackarray0), (pointarray0), (pointdist2array0), (pointrhoarray0))

end sub
 
hi, I clashed with the selection several times, the zoom problem is real, and there is the solution, because with the correct coordinates you should not have problems, it is the safest way to select.
before selectbyid enter
part.setpickmode()

should avoid selecting entities close to the coordinates of your edge
 
hi, I clashed with the selection several times, the zoom problem is real, and there is the solution, because with the correct coordinates you should not have problems, it is the safest way to select.
before selectbyid enter
part.setpickmode()

should avoid selecting entities close to the coordinates of your edge
Hello, thank you for your help.
continue not to work:
  • con Featurefillet3 inside the cycle combines some elements
  • con Featurefillet3 outside, it doesn't work because some elements can't even connect them using the manual command, so it doesn't make one, it can't even do the others.
  • by Featurefillet3 internally od esternamente al cycle change due parametri del command selectbyid2
selectbyid2("", "edge", x_0, delta_y, z, false, 1, nothing, 1)
selectbyid2("", "edge", x_0, delta_y, z, true, 1, nothing, 0)
  • Par. Setpickmode is always within the cycle
  • during program execution the macro window is open and sometimes covers the model, can you change something?
raggio variabile - 2.webpAs you can see, element 7 is not connected and the two precedents, joined together.
 
nothing changes if the graphics area is covered.
you should also turn the model along with the macro to test
 
the maximum radius applicable for those edges is 0.7 mm, with 1 mm does not turn the radius from the third edge onwards.
 
simply from the "agreement" function, can't you do that?
you can select all edges on the bottom plate, from the bar/men that appears to you as soon as you click on one of them:
 

Attachments

  • RACCORDA TUTTI.webp
    RACCORDA TUTTI.webp
    60.3 KB · Views: 12
simply from the "agreement" function, can't you do that?
you can select all edges on the bottom plate, from the bar/men that appears to you as soon as you click on one of them:
Hello, thank you for responding.
I tried, but it doesn't work, it also selects others that don't hit anything.
more than anything else I'm interested in running it through macro to need to vary the number of items.
 
Hello, thank you for responding.
I tried, but it doesn't work, it also selects others that don't hit anything.
more than anything else I'm interested in running it through macro to need to vary the number of items.
very probable, as they have already written above, that the problem is the radius too wide that intersects excessively with the adjacent ones (by curiosity, try to reduce it up to a value that is accepted).
that function collects all the edges found between the vertical extrusions and the bottom; If you don't need someone, you can uncheck them individually by clicking on the "ghost line" of that edge.

but I repeat, you cannot force the system with incompatible rays. not in the same function, at least
 

Forum statistics

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

Members online

No members online now.
Back
Top