Jump to content

Recommended Posts

Posted

Mr. @Tsuky,

Yes,  I used that code.

For example please check this area, coordinate x,y 2517.9362,642.7231

Posted

 

Indeed, this is due to the polyline segment which is not perfectly parallel to the orientation of the text.
What you can try to do is increase the tolerance at line 100. For exemple:

 

(if (equal (rem (angle (car l_vtx) (cadr l_vtx)) pi) (rem ang pi) 7E-02)

 

If this is not enough, increase further within reason.

Posted

For Tsuky working on it. Busy working on a house reno.

 

"Some points have been added in the opposite direction. What could be the reason for this?" one of the things I was looking at was the direction of the drawn pline, if you say put a point on end of pline it may be wrong end, as I am still working on it not sure if lines are consistent direction. Will find if a problem.

Posted

Gentlemen,

 

From what I understand, LISP always adds a dot to the start point of the line.
Is it possible to add point to the end of the Pline that is farthest from Text?
Is it possible to solve this problem like this?

 

image.thumb.png.3bc7d2e93a1fea8a6fac4d6c89b54f81.png

 

Posted (edited)

Ok 1st go 1431 text objects about 2 seconds to change, as per 1st sample dwg supplied. The little search window can be done better. Ver 2. Entmake a point speed increase also.

 

; Modify a pline with text above by Alan H. June 20204

(defun c:tpoint ( / ss ss2 start end x obj obj2 pt1 pt2 pt3 pt4)
(command "-layer" "M" "GPoint2" "C" 5 "" "M" "GLine2" "C" 2 "" "M" "GText2" "C" 1 "" "")
(prompt "Select text to change ")
(setq ss (ssget '((0 . "TEXT"))))
(if (= ss nil)
  (progn (alert "No text selected will now exit")(exit))
)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(repeat (setq x (sslength ss))
  (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
  (setq ins (vlax-get obj 'insertionpoint))
  (vla-GetBoundingBox obj 'minpoint 'maxpoint)
  (setq pt1(vlax-safearray->list minpoint))
  (setq pt1 (mapcar '+ pt1 (list -0.5 -0.5 0.0)))
  (setq pt3 (vlax-safearray->list maxpoint))
  (setq pt3 (mapcar '+ pt3 (list 0.5 0.5 0.0)))
  (setq pt2 (list (car pt3)(cadr pt1)))
  (setq pt4 (list (car pt1)(cadr pt3)))
  (setq lst (list pt1 pt2 pt3 pt4 pt1))
  (setq ss2 (ssget "CP" lst '((0 . "LWPOLYLINE"))))
  (if (= ss2 nil)
    (princ)
    (progn
     (setq obj2 (vlax-ename->vla-object (ssname ss2 0)))
     (setq start (vlax-curve-getstartPoint obj2))
     (setq end (vlax-curve-getEndPoint obj2))
     (vlax-put obj 'Layer "GText2")
     (vlax-put obj2 'Layer "GLine2")
     (setvar 'clayer "GPoint2")
     (command "point" start)
    )
  )
)
(princ)
)
(c:tpoint)

image.png.37ef4b1a4bec70395f5e647b415e4573.png

 

Edited by BIGAL
Posted (edited)

Macros55 the answer to the question of point at wrong end may be solved simply, by answering this question, if these text and plines are generated in some way why are some drawn in reverse direction ? Are you using a lisp to generate them ? That lisp needs to be corrected so line always goes in correct direction. Looks like a MIrror function that needs a Pedit Reverse if implemented.

Edited by BIGAL
Posted
4 hours ago, macros55 said:

Gentlemen,

 

From what I understand, LISP always adds a dot to the start point of the line.
Is it possible to add point to the end of the Pline that is farthest from Text?
Is it possible to solve this problem like this?

 

 

Here is the test that seems to solve the point placement problem.

(if (equal (rem (+ 0.01 (angle (car l_vtx) (cadr l_vtx))) pi) (rem (+ 0.01 ang) pi) 7E-02)

So this tests the angle (in radians) of the polyline segment and the orientation of the text.
The presence of (+ 0.01) is to allow the passage of an angle slightly lower than PI:4th quadrant to the 1st quadrant.
REM is used to compare the angle from 0 to PI
EQUAL to have a close tie at 0.07.

 

After a quick observation of the drawing after execution, the points seem well placed, but I was able to miss a poorly placed point...

Posted (edited)

Gentlemen, you are truly amazing).
Mr. Tsuky and Mr. Bigal, thank you very much.
I really respect the effort you put in.

Edited by macros55
Posted (edited)

I was going to add a point end check may do so, you can get a fuzzy midpoint of text and compare distance to the 2 ends the longer distance is correct point, must have known something left start and end points in code. 

Edited by BIGAL
Posted

Mr. Bigal, Is it possible to speed up the process?

Posted (edited)

Sorry but his logic kills me (if (= ss2 nil). as  opposed to ( if ss2 .🥸

As in is it equal to nothing or is it nothing.

Edited by ronjonp
Posted

ronjonp you are correct to old to change bad habits. :beer:

Posted (edited)

Speed and more speed, your home work is change the (command "point" pt) to a entmake function, just did 1590 text checks and with code change was like blink and you missed it ALL DONE. Took longer to select and press enter than convert.

 

Maybe get a 2nd Hamster for the power wheel. Double the power.

 

image.png.5d84e24076e7e47ae378debcf7505590.png

Edited by BIGAL
  • Funny 2

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