Jump to content

Recommended Posts

Posted

This may be a question no one has had to answer, I have a client dwg with 3dplines, each vertex has a block attached, I can get all the pline vertices xyz etc no problems, I have used ssget "F" vertlist,  to find the blocks at the corresponding point, I then do some stuff with the matching point attributes creating a new 3dpoly. I should point out it all works except for the dropped points. 12 3dpoly's 2 points missing. 

 

The issue is that for some reason it will leave either 1st or last point out I have 11 vertices but only 10 blocks are found, yes the blocks and vertices exactly match xyz. What makes it even more complicated is it seems random on which pline it leaves point out. 

 

I have tried zooming to pline making sure all is in world etc. 

 

The sample fugded dwg works correct so that does not help, I can not post the client dwg. 

 

I am trying to avoid a global list of all the block insert points and having to compare to vertex point. 

 

Any one have an idea.

 

Posted

The problem lies in the selection "F" of ssget, in my opinion. I'm telling you this because I have some problems with ssget "F", when working on Gauss-Boaga coordinates (I work in the road sector), which for my area are about 2300000,5050000. I tried moving the drawing momentarily to coordinates 0,0 and magically it worked! I don't know if this is it, but it's worth giving it a try.

Posted (edited)

Hello @BIGAL i use this for select block at polyline.

 

(defun c:vsel (/ sel1 sel2 selVod selXT)

(setq sel1 (ssget (list (cons 0 "LWPOLYLINE") (cons 8 "XX"))))

(setq sel2 (ssget "X" (list (cons 0 "Insert") (cons 2 "XXX"))))

(setq selVod (VaniVL sel1 "try1"))

(setq selXT (VaniVL sel2 "try2"))

(setq sel3 (ssadd))
(vlax-for x selVod
		(vlax-for y selXT
			(progn
				(if (equal (vlax-curve-getClosestPointTo x (vlax-get y 'InsertionPoint)) (vlax-get y 'InsertionPoint) 0.01)
					(ssadd (vlax-vla-object->ename y) sel3)
				)
			)
		)
)
(sssetfirst nil sel3)
(princ)
)

(defun VaniVL ( SS SSnm / i L SScoll SfArrayObjs vSS )
  (cond
    ( (not (eq 'PICKSET (type SS))) nil)
    ( (not (and (eq 'STR (type SSnm)) (snvalid SSnm))) nil)
    (T
      (repeat (setq i (sslength SS))
        (setq L (cons (vlax-ename->vla-object (ssname SS (setq i (1- i)))) L))
      )
      (setq SScoll (vla-get-SelectionSets (vla-get-ActiveDocument (vlax-get-acad-object))))
      (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-Item (list SScoll SSnm))))
        (vla-Delete (vla-Item SScoll SSnm))
      )
      (setq vSS (vla-Add SScoll SSnm))
      (setq SfArrayObjs (vlax-make-safearray vlax-vbObject (cons 0 (1- (length L)))))
      (setq i -1)
      (foreach o L (vlax-safearray-put-element SfArrayObjs (setq i (1+ i)) o) )
      (vla-AddItems vSS SfArrayObjs)
      vSS
    )
  ); cond
); defun VanillaSS->VlaSS

 

Edited by Trudy
Posted

Confutatis  X = 299637.171     Y = 1223038.583     Z = 232.937 may be the problem. Maybe set UCS OR to a point so smaller X Y . 

 

Trudy will look at code in more detail, its comparing the two lists finding matches.

Posted

In order to avoid the problems with the coordinates transposition, I preferred to physically move the drawing, or the part of the drawing directly near the 0,0 coordinates of the WCS.

Posted

Ssget F works not based on whether the object is actually touching the object, but rather if you can actually "see" it touching the object in plain sight.

 

Here's an image of a circle and a line from four different views. From top-left clockwise: Top, Left, SE Isometric, Front. I've attached a dwg for you to try it out as well. You can clearly see that (geometrically) the line is not touching the circle at all. However in the SE Isometric, the line is (visually) crossing the circle just by "seeing" it. Doing ssget F on the two endpoints of a line on the top, left and front views will only get you the line, but do it in the SE Isometric view and you'll get the circle too. You can try it with this:

 

image.thumb.png.42950922202f1411cbbf658377b10a8d.png

 

(ssget "_F" (list (getpoint) (getpoint)))

 

Therefore I would go about the approach that Trudy has taken. This one opts for single selection of curves instead.

 

(defun c:foo ( / tol pl rtn ss i ent enx)
    (setq tol 1e-6)
    (while
        (progn
            (setvar "errno" 0)
            (initget "Exit")
            (setq pl (entsel "\nSelect curve [Exit] <exit>: "))
            (cond
                (   (= (getvar "errno") 7) (princ "\nNothing selected."))
                (   (member pl '("Exit" nil)) nil)
                (   (not (wcmatch (cdr (assoc 0 (entget (setq pl (car pl))))) "LINE,*POLYLINE,ARC,ELLIPSE,XLINE,RAY,SPLINE,HELIX"))
                    (princ "\nObject is not a curve")
                )
            )
        )
    )
    (and
        pl
        (setq rtn (ssadd) ss (ssget "_X" (list '(0 . "INSERT") (assoc 410 (entget pl)))))
        (progn
            (repeat (setq i (sslength ss))
                (setq i (1- i) ent (ssname ss i) enx (entget ent))
                (if
                    (equal (setq pt (cdr (assoc 10 enx))) (vlax-curve-getclosestpointto pl pt) tol)
                    (setq rtn (ssadd ent rtn))
                )
            )
            (sssetfirst nil rtn)
        )
    )
    (princ)
)

 

Test.dwg

Posted

Thank you all.

 

Johnathon, yes was aware of fence must look down so was resetting ucs and Plan etc it would just miss odd end or start point.

 

Confutatis yes seemed to work moving all the blocks and line work to 0,0 setting a ucs did not work. Worked once but then I screwed something up and stopped working.

 

Trudy I am going down that path now I am using 2 lists, I compare the co-ordinates get a match and retrieve attribute value, then make a new list of X Y newZ. I don't use vlax curve no need to. Its early days, almost done. The blocks and co-ords match exactly so that helps. Its repeat ssname and foreach double loop.

 

 

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