PDA

View Full Version : Fillet Issue


prose
2009-03-23, 07:59 PM
I have a quick question for you.
I have the below code and it works well.
The problem is, if both lines are polylines it wont work.
Any ideas as to why.
Thanks in advance.


;;;---------------------------------------------
;;;Creates a 6" Fillet putting objects on first selected layer
;;;
(defun C:fillet6 (/ fr)
(while (not (setq s1 (entsel "Select line to fillet on target layer")))
(princ "\nNull Selection please try again: ")
)
(while (not (setq s2 (entsel "Select line to fillet to put on target layer")))
(princ "\nNull Selection please try again: ")
)
(setq fr (getvar "filletrad"))
(command "matchprop" s1 s2 "")
(command "fillet" "Radius" "6")
(command "fillet" s1 s2)
(setvar "filletrad" fr)
(prompt "\nFillet and layer change was successful")
(princ)
)

icbinr
2009-03-23, 11:53 PM
I'm inclined to say this is a bug.

I can make it work by typing each line of code at the command line. But if I cut and paste it all back and load it as a command. It has issues with the FILLET command.

prose
2009-03-24, 12:04 AM
I'm inclined to say this is a bug.

I can make it work by typing each line of code at the command line. But if I cut and paste it all back and load it as a command. It has issues with the FILLET command.

I had the same issue. I just wanted to make sure that I didn't do anything wrong or funky with the code as I am still learning lisp.

I wonder if there is a work around.:?

icbinr
2009-03-24, 12:05 AM
If you run the following code you can see what I mean.


(defun C:fillet6 (/ fr)
(while (not (setq s1 (entsel "Select line to fillet on target layer")))
(princ "\nNull Selection please try again: ")
)
(while (not (setq s2 (entsel "Select line to fillet to put on target layer")))
(princ "\nNull Selection please try again: ")
)
(setq fr (getvar "filletrad"))
(setvar "filletrad" 6.0)
(command "._matchprop" s1 s2 "")
(command "._fillet" (cadr s1) (cadr s2))
(setvar "filletrad" fr)
(prompt "\nFillet and layer change was successful")
(princ)
)


Now after you have run it. Do the following from the Command Line...



(command "._fillet" (cadr s1) (cadr s2))


It should have worked at that point.

Now take a look at your Text Window... You'll notice that when you ran the FILLET6 command. It asked to select the first object twice. And if you selected the first entity you originally chose. It will fillet the two PLINES. Just not the way it was intended to.

Command: ._fillet
Current settings: Mode = TRIM, Radius = 6.00
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]:
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]:
Select second object or shift-select to apply corner:
Fillet and layer change was successful

But when you run the second piece of code from the command line it doesn't.

prose
2009-03-24, 04:39 PM
Does it have something to do with "entsel" not able to select polylines? :?
I know there has to be a way to do this. Any more suggestions would be great.

icbinr
2009-03-24, 05:42 PM
I was able to make it work a couple of ways but both were very sketchy.

One way was to change your ENTSEL for GETPOINT and just pick a point near the objects.

The drawback to that is the object doesn't highlight. So you don't know if you actually got it or not. You also can't use your WHILE to loop until an object is selected.

The other was even more oddball because it involved selecting the first object, then the second object, then if both were PLINES I had to choose the first one again.

What would probably be the easiest is to check if the object are PLINES and explode them if they are. Drawback to that is that if you have a complex PLINE you might not want it to be exploded.

What has me totally confused about your problem is that I can make it work from the command line but not as part of a routine. Also that I can use GETPOINT and select a point near the objects and it works but I can't use the CADR of your ENTGET and make it work despite the two points being obtained in basically the same way.

BoKirra
2009-03-25, 03:26 AM
I have a quick question for you.
I have the below code and it works well.
The problem is, if both lines are polylines it wont work.
Any ideas as to why.
Thanks in advance.


(defun C:fillet6 (/ fr)
...
)

The solution should be
1) FIRST of all, to check if the entity is LINE or POLYLINE by using DXF function.
i.e. "entget" possibly.
2) then execute the fillet function.
But I can't help further because I'm a year 1 pupi....... :Oops:

irneb
2009-03-25, 02:37 PM
Change the (command "._fillet" (cadr s1) (cadr s2)) to this (command "._fillet" s1 s2).

irneb
2009-03-25, 03:15 PM
To get around the prob of (command "._fillet" ...) not working on 2 polylines, you could always just explode one of them. Then use ssget with the 2nd portion of the exploded entsel return to get the line / arc passing through the picked point. Fillet that line/arc with the remaining polyline. Then PEDIT the new polyline & joint the lines / arcs of the exploded one to it.

icbinr
2009-03-25, 03:45 PM
Change the (command "._fillet" (cadr s1) (cadr s2)) to this (command "._fillet" s1 s2).

That doesn't work either.... I couldn't even get it to work from the command line.

icbinr
2009-03-25, 03:55 PM
The problem here is that for some reason when both objects are PLINE objects. The first symbol S1 is ignored and the second symbol S2 is accepted when it prompts the second time for the first object.

Command: ._fillet
Current settings: Mode = TRIM, Radius = 6.00
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: <--- Should have been S1
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: <--- Accepted S2
Select second object or shift-select to apply corner: <--- Asks for input again.
Fillet and layer change was successful

This only happens if S1 and S2 are PLINE objects.

irneb
2009-03-25, 04:34 PM
That doesn't work either.... I couldn't even get it to work from the command line.I know :mrgreen:, that's why my next post. How do you get it working at the command prompt ... it doesn't do anything when I try that? Do you mean when you simply type FILLET?

The problem here is that for some reason when both objects are PLINE objects.That's why I suggest the convoluted method of exploding one of the plines if both are plines. Then joining all after the fillet. It's just going to make your function a lot more complex.

prose
2009-03-25, 06:57 PM
Is it possible to create a selection set list that includes lines and polylines, so when you click each line it will recognize it? I am not that skilled when it comes to creating selection sets in lisp.

icbinr
2009-03-25, 09:56 PM
It's not very pretty but it works.


(defun C:FILLET6 (/ fr s1 s2)
(princ "\nSelect line to fillet on target layer")
(setq s1 (ssget ":S"))
(princ "\nSelect line to fillet to put on target layer")
(setq s2 (ssget ":S"))
(setq fr (getvar "FILLETRAD"))
(setvar "FILLETRAD" 6.0)
(command "._MATCHPROP" s1 s2 "")
(vl-cmdf "._FILLET" s1 s2)
(setvar "FILLETRAD" fr)
(prompt "\nFillet and layer change was successful")
(princ)
)


Now what's really odd is I tried using (SSADD (CAR s1)) to create a selection set from the ENTSEL and that does not work. But using the SSGET ":S" does. I'm not sure why but using ENTSEL has issues with the PLINE objects.... It's not just a 2009 problem either. I tried it in 2005 and had the exact same problems.

prose
2009-03-25, 10:10 PM
It's not very pretty but it works.


(defun C:FILLET6 (/ fr s1 s2)
(princ "\nSelect line to fillet on target layer")
(setq s1 (ssget ":S"))
(princ "\nSelect line to fillet to put on target layer")
(setq s2 (ssget ":S"))
(setq fr (getvar "FILLETRAD"))
(setvar "FILLETRAD" 6.0)
(command "._MATCHPROP" s1 s2 "")
(vl-cmdf "._FILLET" s1 s2)
(setvar "FILLETRAD" fr)
(prompt "\nFillet and layer change was successful")
(princ)
)


Now what's really odd is I tried using (SSADD (CAR s1)) to create a selection set from the ENTSEL and that does not work. But using the SSGET ":S" does. I'm not sure why but using ENTSEL has issues with the PLINE objects.... It's not just a 2009 problem either. I tried it in 2005 and had the exact same problems.

Thank you, works great. This issue has driven me nuts for the last few weeks and I couldnt get past it with my limited knowledge. Thanks for all your help.

irneb
2009-03-26, 06:43 AM
Brilliant! Much simpler than my solution! 8) This is extremely strange, don't know why entsel has these problems with polylines. Is it just with LWPolylines or does it do the same with the old "Heavy Weight" pl's?

Just a word of warning (although prose's code is correct the OP code would cause problems): When using selection sets, be sure to change their variables to nil after you've finished with them. Easiest way is to declare them as local inside the defun (as prose has done). Otherwise you would need a (setq s1 nil s2 nil) at the end.

The reason for this is: there's a limit on the amount of open selection sets. Once this limit is reached no more selections can be done. So if you place the selection set in a global variable, it stays open. Only after the variable is set to nil and garbage collection's happened is the selection set released.

Shouldn't be a problem with just the one function, but then you don't know if you've got other function which do something similar. Better to just do the localize / setq nil. If your ssget is inside a loop you may even want to do the setq nil as well as a gc just after ... you don't know how many times the loop will iterate before a background gc happens.

icbinr
2009-03-26, 03:18 PM
That's actually my code based on prose's original code. =+)

I didn't try it on any legacy PLINE objects.

I'm still convinced it's some kind of bug/glitch but I can't wrap my head around why it is happening.

Why can I use ssget to create the selection set but I can't use ssadd on the car of the entsel and create a selection set and make it work? Both are selection sets containing the ename of the object.

Even more confusing..... I am feeding the Fillet command two symbols. The symbols can contain either a PLINE or a LINE.

If the two symbols equal a line. It works
If the two symbols contain one line and one pline. It works
If the two symbols equal a pline... It doesn't work.

How does it know that second symbol is a PLINE before the command has processed it?

irneb
2009-03-26, 03:58 PM
Sorry, mind's going I suppose :Oops:.

I think the reason is that the FILLET command expects more than just an ename. It needs a pick point as well, since some entity types would fillet differently depending on where they were picked.

But entsel gives exactly that (an ename followed by the pick point). So you're correct, this appears to be a bug. SSADD itself works with only enames, not with ename + point. The SSGET is the only way to get a selection set which includes the pick points.

You could also (if you wanted to use the points somewhere else) have done the normal entsel, then using (SSGET (cadr s1)) send that point again to get a selection set with points. So now you have the selection set (which works with polylines) as well as the entsel with picked point. Of course this would only be needed if you wanted to do something with those points.

Or :mrgreen: ... you could try and work out the picked point from the list returned by SSNAMEX. For example this returns ((1 <Entity name: 6fb0d9a8> 0 (0 (57333.0 8386.98 0.0)))) after I've sent the previous solution. It would have been easy to create this from the entsel, and then ssadd it ... but unfortunately ssadd only accepts enames ... and there's no way to directly edit the selection set in LISP:roll: