|
selecting faces for mates
i need to replace lots of parts in lots of assemblies. i have in mind to name some faces of the parts and use those faces for editing the mates. that way when i get ready to replace some bolts i'll name the threaded part "thread" and use that for concentric mates. i'm having trouble when i try to select the face with the selectbyidid2 using"thread@bolt-3@assm ,face" it doesn't get selected. another way i tried to select the face, was to traverse the faces until i found the name, then set face to that face but that doesn't add the face to the selection for mating and i'm having trouble finding the correct selection code. i think it would be the same code needed when a face is selected and set using "set face = sm.getselectedobject5(1) ".
problem two is that i have a program that goes through an assembly and finds invalid mates then gets the existing component to that mate but i haven't figured out how to get the face that the mate goes to.
i will sure appreciate any help with this.
thanks
dan miel
2008 sp4
edited: 10/23/2008 at 12:12 am by dan miel
hi dan
attached you can find the code to select a named face
you can find this code in the api help under
"select component face by name example (vb)"
public function selectcomponentfacebyname(byval comp as sldworks.component2, byval facename as string) as sldworks.face2
dim body as object
dim face as sldworks.face2
dim curfacename as string
dim retval as boolean
const swselcomponents = 20
set body = comp.getbody() ' get the component body
set face = body.getfirstface
comp.deselect
' traverse thru all body faces
do while not face is nothing
curfacename = assdoc.getentityname(face)
if (curfacename = facename) then
face.select (0) ' select the face
set body = nothing
set selectcomponentfacebyname = face
exit do
end if
set face = face.getnextface
loop
end function
for your second problem maybe the code in the api help under
"get mates and mate entities example (vb)"
helps
regards
heinz
you may also find it beneficial to understand how the selectbyid2 strings should be constructed. i wrote a guide
luke
i see that you copied the information from your book to your webpage. i have looked at that page several times and i retried changing the id from "thread@bolt-3@assm1 ,face" to "thread@extrude1@bolt-3@assm1 ,face" but the selectbyid still doesn't pick it up. i reference your book quite often, it is helpful.
heinz
i used that example to find the face but after i find the two faces i'll need to select them both to edit the mate. if i make a macro to add or edit mates, there are two faces selected just before the mate is added. i'm having trouble finding a selection method to select both face1 and face2.
thanks for your input.
dan
hi dan
i made that this way
set f1 = selectcomponentfacebyname(comp1, "k_mantel")
set f2 = selectcomponentfacebyname(schln, "schln_mantel")
f1.select (0)
f2.select (1)
assdoc.addmate3 swmateconcentric, swmatealignaligned, false, 0, 0, 0, 0, 0, 0, 0, 0, false, longstatus
hope this helps
p.s.
sorry about my english :-(
heinz
i created a program this weekend that gets the faces and edits the mate using the code you put here, thank you. one of the things that was confusing me was that there needs to be a third selection for the editmate line: m1.select(3), where the m1 is the mate to be edited.
luke
in your book you say to use select4 for selecting faces. is the select4 a better code than just select? i did notice that select4 returns the data object also, so is that the reason for select4?
thanks
dan miel
quick |
|