|
sketch macro
hey guys,
i have a need to modify a sketch's sharp corners to something simlar to a fillet.
i recorded a macro which was less than helpful the issue i have is that when i record a macro it gives me the standard:
boolstatus = part.extension.selectbyid2("line1", "sketchsegment", -0.08898693897835, 0.01998979925235, 0, false, 0, nothing, 0)
where it is selecting a sketch seg already named "line1" or "line2" and working with it and for me that wont work.
the way i want mine set up is to find all outside sharp corners and treat them with a series of fillets. (see below)
basically i would need to edit up to 30 sketches and perform this macro. so the sketch segments named "line1" or whatever the name may be is irrelevant. however i do need to select the point of each sharp corner and then the lines that extend from that point to make sure i am drawing the fillets in the right direction.
i am not real familiar with drawings shapes within macros or editing existing sketches.
any resources or advice would be appreciated
thanks!
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
jake,
this is a pretty complicated task. you can get all of the sketch segments in a sketch using the method "sketch.getsketchsegments". you can then loop through the segments and find out what type of sketch entity it is using method "sketchsegment.gettype". if the segment is a sketchline, get it's start and end points. you would then have to find the lines that share start/end point to get the corners and what lines are connected there. you would then need to determine if this corner is inside or outside. i think you could do this by having the user screen select a location inside the 2d sketch profile. you could then check this point location with respect to the two lines. if it is an inside corner the create the arc and fillet between it and the two lines.
wayne matus
texas engineering systems
if you are only adding fillets to external perimeters and not complex hollowed profiles too (such as interior cuts) then the task becomes much simplier.
you can determine the outside perimeter fairly easily and have a collection of entities. from that you then do your loop and the tricky part is determining the inner/outer preference.
to determine the orientation you need to select a start line and class the outside as being to the left of the normal direction, as you follow the loop class the outside as the left of the normal to all of the first lines out of the 2 that make the point. this will place the fillets in the same direction for that loop (inside or outside). then you can just offer the user a "flip" option to change the direction to right. you can add an undo command at the start of your code to remove and changes and re-add the fillets.
creating the fillets is then childs play.
still quite a lot of work depending on your skill level though, and then you need to add the folder browsing/file selecting process and a loop to process all files but again that is relatively simple.
thanks guys, this is the direction i was aiming for. i have about half of this completed although it is getting trickier now. i'll keep you posted though!
as for my exp: i have been a software developer for about 10 yrs. all my work has been in c++/vb and vfp (any fox pro users out there? lol) it was all erp based development. lots of database interaction via code and whatnot
anyway i would like to think i am pretty versed in oop in multiple languages. my weakness is that i am pretty new to this particular api so my "toolbox" is empty so to speak.
i read through sketch object pretty extensively last night and that opened a bunch of doors. basically i am getting familiar with the object model as i am developing things! needless to say... my first few macros are probably a little messy / inefficient!
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
edited: 10/23/2008 at 07:21 am by jake johnson
i have never had a chance to use macros to edit a sketch so this looks like a complicated task to me, adding the sketch fillets like are shown in your picture and then hopefully fully defining the sketch
have you given any thought to adding a new feature. find the corners of a face of the part then add a predefined sketch to the corners and extruding or base-flange/tab if it is sheet metal, this could even be a block inserted, or even create a design library feature part and add that to the corners
showing all the reasoning and logic behind this code would make a good swugn presentation
cswa, cswp, cswp-smtl, sw 2009 sp2.0
hp xw4600 xp32, x9650 4gb, quadro fx3500
that would be good for a particular cnc problem that comes up. i suggest making a block. define dimensions that are editable, and constrained, maybe add values that you can edit without having to open the perameters. since your are changing a 90degree angle it should be easy to define.
edited: 10/31/2008 at 02:41 am by nathaniel taylor
true 90's would be easy although in my case there could be all sorts of angles (inside and outside)
i was actually broken off of this project to work on another one but i did make some significant progress on it while i was working on it. i plan on getting back into the code later this month!
i'll post back here as i progress.
solidworks professional 2009 sp0
dual core amd opteron 2.21ghz cpu
4 gb ram
nvidia quadrofx 4500 w/ 512mb ram
quick |
|