Jump to content

Recommended Posts

Posted

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)
)

 

Posted

pretvara ne u dotted parove, vec u listu sa sublistama tripleta koordinata...

Posted

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

Posted
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

 

Posted
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...

Posted
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)))))

 

 

Posted
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...

Posted

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...

Posted
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... 

Posted

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...

Posted

This means bpnt is not on the polyline in the variable alignment, but off one of the ends.

Posted
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)))

 

Posted

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... 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...