Tomislav Posted July 17, 2020 Posted July 17, 2020 Hello. I'm using 'IntersectWith to find intersections of 2dpolylines and usually it works fine, but every so often I get 'bad argument type: numberp: nil' , so how to avoid that, thank you below is part that does it... (setq intlst (gr3 (vlax-invoke alignment 'IntersectWith profile acExtendOtherEntity ) ) bpnt (car intlst) ) (defun gr3 ( lst / rtn ) ; pretvara listu koordinata u dotted parove po 3 koord (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) (reverse rtn) ) Quote
marko_ribar Posted July 17, 2020 Posted July 17, 2020 pretvara ne u dotted parove, vec u listu sa sublistama tripleta koordinata... Quote
Tomislav Posted July 17, 2020 Author Posted July 17, 2020 ma to sam ja onako 'po seljački' sebi objasnio ali mislim da nije to problem nego kao da nekad cad ne može pronaći presjek Quote
dlanorh Posted July 17, 2020 Posted July 17, 2020 1 hour ago, Tomislav said: Hello. I'm using 'IntersectWith to find intersections of 2dpolylines and usually it works fine, but every so often I get 'bad argument type: numberp: nil' , so how to avoid that, thank you below is part that does it... (setq intlst (gr3 (vlax-invoke alignment 'IntersectWith profile acExtendOtherEntity ) ) bpnt (car intlst) ) (defun gr3 ( lst / rtn ) ; pretvara listu koordinata u dotted parove po 3 koord (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) (reverse rtn) ) You are only extending the profile. If the alignment doesn't cross the profile no intersection will be found thus bpnt = nil. Try with acExtendBoth Quote
Tomislav Posted July 17, 2020 Author Posted July 17, 2020 22 minutes ago, dlanorh said: You are only extending the profile. If the alignment doesn't cross the profile no intersection will be found thus bpnt = nil. Try with acExtendBoth Hello. It's not happening on the ends and I rarely have profiles on the ends so extending is almost never used. It's happening along alignment as if CAD can't find intersection. Right now I'm solving it by offsetting profile by 1cm and then it works fine but how to resolve this... Quote
dlanorh Posted July 17, 2020 Posted July 17, 2020 2 hours ago, Tomislav said: Hello. It's not happening on the ends and I rarely have profiles on the ends so extending is almost never used. It's happening along alignment as if CAD can't find intersection. Right now I'm solving it by offsetting profile by 1cm and then it works fine but how to resolve this... Try this snippet (setq elst (list acExtendNone acExtendThisEntity acExtendOtherEntity acExtendBoth) cnt 0 ) (while (not bpnt) (setq intlst (gr3 (vlax-invoke alignment 'IntersectWith profile (nth cnt elst))) bpnt (car intlst) ) (cond ( (and (not bpnt) (=> cnt 3)) (alert "No Intersections Found Lines are parallel")) ( (not bpnt) (setq cnt (1+ cnt))) ) ) (defun gr3 (lst) (if lst (cons (cons (car lst) (cons (cadr lst) (cons (caddr lst) nil))) (gr3 (cdddr lst))))) Quote
Tomislav Posted July 17, 2020 Author Posted July 17, 2020 1 hour ago, dlanorh said: Try this snippet (setq elst (list acExtendNone acExtendThisEntity acExtendOtherEntity acExtendBoth) cnt 0 ) (while (not bpnt) (setq intlst (gr3 (vlax-invoke alignment 'IntersectWith profile (nth cnt elst))) bpnt (car intlst) ) (cond ( (and (not bpnt) (=> cnt 3)) (alert "No Intersections Found Lines are parallel")) ( (not bpnt) (setq cnt (1+ cnt))) ) ) (defun gr3 (lst) (if lst (cons (cons (car lst) (cons (cadr lst) (cons (caddr lst) nil))) (gr3 (cdddr lst))))) will do... Quote
marko_ribar Posted July 17, 2020 Posted July 17, 2020 Proveri da li je crtez (krive koje se seku) blizu koordinatnog pocetka - tacke 0,0,0... Intersectwith metod je poznat po tome sto je buggy, ako se kalkulacije desavaju sa velikim koordinatama... Inace isto vazi i za sve ostale kalkulacije u CAD-u - ako su brojevi enormno veliki ili obrnuto enormno mali, CAD gresi, a verujem i bilo koji drugi program na PC-u... Quote
Tomislav Posted July 17, 2020 Author Posted July 17, 2020 3 hours ago, marko_ribar said: Proveri da li je crtez (krive koje se seku) blizu koordinatnog pocetka - tacke 0,0,0... Intersectwith metod je poznat po tome sto je buggy, ako se kalkulacije desavaju sa velikim koordinatama... Inace isto vazi i za sve ostale kalkulacije u CAD-u - ako su brojevi enormno veliki ili obrnuto enormno mali, CAD gresi, a verujem i bilo koji drugi program na PC-u... čuj, koordinate su geodetske za naše podneblje, znači x,y,z = 600000,5000000,90... zanimljivo kad sam pokušavao ponovo pronaći grešku sa dodatkom od dlanorh, ne mogu je pronaći... look, the coords are surveyors for our local, meaning x,y,z = 600000,5000000,90... whats interesting, when trying to repeat my steps and find that error with the addition of dlanor's snippet, I can't seem to find it... Quote
Tomislav Posted July 18, 2020 Author Posted July 18, 2020 I actually found that it's not problem in that but in this (setq distAtPoint (vlax-curve-getDistAtPoint alignment bpnt)) it can't get distance... Quote
dlanorh Posted July 18, 2020 Posted July 18, 2020 This means bpnt is not on the polyline in the variable alignment, but off one of the ends. Quote
Tomislav Posted July 18, 2020 Author Posted July 18, 2020 3 minutes ago, dlanorh said: This means bpnt is not on the polyline in the variable alignment, but off one of the ends. yea, an I solved it with (setq distAtPoint (vlax-curve-getDistAtPoint alignment (vlax-curve-getClosestPointTo alignment bpnt T))) Quote
Tomislav Posted July 18, 2020 Author Posted July 18, 2020 it seems that sometimes the curvature or imprecision in autocad gives that bpnt (intersection of profile and alignment) aside of alignment and not on it, and thus, no distance... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.