vla-intersectwith shortcoming

vla-intersectwith shortcoming

john.uhden
Mentor Mentor
2,061 Views
24 Replies
Message 1 of 25

vla-intersectwith shortcoming

john.uhden
Mentor
Mentor

Although Land Desktop has a routine for labeling the elevation of polyline contours, it often misbehaves.  So naturally I wrote my own.  The object is to pick the polyline at the desired label point, extract the elevation, add the text aligned with the polyline, and break the polyline from one end of the text to the other.  Sadly, 2004 doesn't have background masking, and the boss despises wipeouts, thus we must break the polyline.

My method was to create an invisible circle, find the intersects, and use them as the two break points.

After some trial and error, I have found that the method does not work when the circle intersects one bulged segment twice.  Even the native TRIM command won't work.  If one of the intersections is with a straight polyline segment, it does work.

Has anyone else experienced this behavior?  Or maybe it was a bug that's been fixed since 2004.

John F. Uhden

0 Likes
Accepted solutions (3)
2,062 Views
24 Replies
Replies (24)
Message 2 of 25

CodeDing
Advisor
Advisor

@john.uhden ,

 

I can't speak to if it's been fixed since 2004, but can you post an example dwg?

0 Likes
Message 3 of 25

cadffm
Consultant
Consultant

Hi @john.uhden ,

Check the dxf codes for background mask on MText.

Backgroundmask is available in 2004 also!

(Only for programmers! There wasn't a way for Users before 2005, but the MText-Object was ready for it, so you can create/edit MTexts with a background.

Sebastian

0 Likes
Message 4 of 25

john.uhden
Mentor
Mentor

I must have been doing something wrong with the TRIM command.  That is working better unless the circle and polyline are at different elevations.

You don't need a sample drawing.  Just draw a bulged polyline and a circle at roughly its midpoint.  Try them at the same and differing elevations.

John F. Uhden

0 Likes
Message 5 of 25

john.uhden
Mentor
Mentor

I solved the problem by using a polygon instead of a circle.  It's slower, but no big deal.  I think I'll reduce the number of sides from 20 to 10.

John F. Uhden

0 Likes
Message 6 of 25

dlanorh
Advisor
Advisor

You could use a bulged polyline as a circle. Polyline from x to y to x (diameter of circle) and set bulges 0 & 1 to 1.0

I am not one of the robots you're looking for

0 Likes
Message 7 of 25

john.uhden
Mentor
Mentor

Wow!  That's heavy news.  I'll try it out with code I had for 2008.

John F. Uhden

0 Likes
Message 8 of 25

john.uhden
Mentor
Mentor

That's clever too.  But it's fixed right now, so I don't wanna break it again.

John F. Uhden

0 Likes
Message 9 of 25

john.uhden
Mentor
Mentor

Alas, though, the problem may still exist that vla-intersectwith doesn't like a circle and a bulged polyline segment.  That's annoying to me yet not the first work-around I've had to employ.  I think PEDIT;Join was another.

John F. Uhden

0 Likes
Message 10 of 25

john.uhden
Mentor
Mentor
Sadly...
Command: (vlax-property-available-p object 'backgroundfill)
nil

Here are the DXF codes in 2004...
(-1 . )
(0 . "MTEXT")
(330 . )
(5 . "1CDA6")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "AB-SAN-TXT")
(100 . "AcDbMText")
(10 7227.27 5300.56 0.0)
(40 . 3.0)
(41 . 50.2946)
(71 . 1)
(72 . 5)
(1 . "San. MH 1A\\PRim 29.89\\PInv. 15.88")
(7 . "SL60")
(210 0.0 0.0 1.0)
(11 0.769845 -0.638231 0.0)
(42 . 26.1818)
(43 . 13.0)
(50 . 5.59099)
(73 . 1)
(44 . 1.0)

I don't see a 45 code for offset, and I think the 7x codes are for
alignment, so I don't recognize any code for backgroundfill.

John F. Uhden

0 Likes
Message 11 of 25

Kent1Cooper
Consultant
Consultant
Accepted solution

@john.uhden wrote:

....  The object is to pick the polyline at the desired label point, extract the elevation, add the text aligned with the polyline, and break the polyline from one end of the text to the other.  ....

My method was to create an invisible circle, find the intersects, and use them as the two break points.

....


 

You can avoid this problem by using the Text itself  as a TRIM boundary -- see LabelTextTrim.lsp with its LTT command, >here<.  It asks the User for Text content, but you should be able to apply its TRIM operation in yours.  [I also have one that extracts elevation for the Text content as you describe, but it uses a Mask instead of Trimming.]

Kent Cooper, AIA
0 Likes
Message 12 of 25

ronjonp
Mentor
Mentor

@john.uhden wrote:
Sadly...
Command: (vlax-property-available-p object 'backgroundfill)
nil

Here are the DXF codes in 2004...
(-1 . )
(0 . "MTEXT")
(330 . )
(5 . "1CDA6")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "AB-SAN-TXT")
(100 . "AcDbMText")
(10 7227.27 5300.56 0.0)
(40 . 3.0)
(41 . 50.2946)
(71 . 1)
(72 . 5)
(1 . "San. MH 1A\\PRim 29.89\\PInv. 15.88")
(7 . "SL60")
(210 0.0 0.0 1.0)
(11 0.769845 -0.638231 0.0)
(42 . 26.1818)
(43 . 13.0)
(50 . 5.59099)
(73 . 1)
(44 . 1.0)

I don't see a 45 code for offset, and I think the 7x codes are for
alignment, so I don't recognize any code for backgroundfill.

@john.uhden 

Does this work for you? Should create a red background mask.

 

(if (setq e (car (entsel "\nPick MTEXT: ")))
  (entmod (append (entget e) '((90 . 1)(63 . 1))))
)
(if (setq e (car (entsel "\nPick MTEXT: ")))
  ;; Same as color background
  (entmod (append (entget e) '((90 . 3) (63 . 256))))
)

 

0 Likes
Message 13 of 25

john.uhden
Mentor
Mentor
Yes, it does. I presumed code 63 is for the color, but I can't seem to
pick a number for no color.
Can I append the 45 code for the offset?

John F. Uhden

0 Likes
Message 14 of 25

cadffm
Consultant
Consultant

Ok, it's too late now, but

 

 

>"(vlax-property-available-p object 'backgroundfill)"
Has nothing to do with Groupcodes 🙂 [it looks like that backgroundfill came with the official background start: Ver2005]

>"Here are the DXF codes in 2004... - I don't see a 45 code for offset,"
Where is Groupcode 62 in a Entitylist of a object with color "ByLayer"?
If not present, APPEND the dottedpair list.

90 - 3 BackgroundColor as Color, or 90 - 1 for your color
63 ACU Color
45 Offset

 

; Simple sample code for only ACI colors

(defun TEST (#90# #63# #45# / #el# #TEMP#) ;; TEST-> (TEST 3 9 1) or (TEST 1 4 3)
(while
(setq #el# (entget(car (nentsel "\nMtext wählen: "))))
;;================================================================
(if (assoc 90 #el#)
(setq #el# (subst (cons 90 #90#) (assoc 90 #el#) #el#))
(setq #el# (append #el# (list (cons 90 #90#))))
)
;;================================================================
(if (assoc 63 #el#)
(setq #el# (subst (cons 63 #63#) (assoc 63 #el#) #el#))
(setq #el# (append #el# (list (cons 63 #63#))))
)
;;================================================================
(if (assoc 45 #el#)
(setq #el# (subst (cons 45 #45#) (assoc 45 #el#) #el#))
(setq #el# (append #el# (list (assoc 45 #el#)))) ;
)
;;================================================================
(entmod #el#)(princ)
)
)

 

EDIT: Change the line ;; TEST-> (TEST 3 9 1) or (TEST 1 4 3)

 DXF Codes Help MTEXT

Sebastian

0 Likes
Message 15 of 25

ronjonp
Mentor
Mentor

This worked for an offset here:

 

(if (setq e (car (entsel "\nPick MTEXT: ")))
  ;; Same as color background with 1.5 offset
  (entmod (append (entget e) '((90 . 3)(45 . 1.5))))
)

 

 

 

 

0 Likes
Message 16 of 25

cadffm
Consultant
Consultant

@cadffm  schrieb:

Has nothing to do with Groupcodes 🙂 [it looks like that backgroundfill came with the official background start: Ver2005]

 


Confirm. The backgroundfill property for the ActiveX Model came with the official Mtext-Background start in Ver2005,

From 2005 German Help doc about Changes:

Hinzufügen der BackgroundFill-Eigenschaft zum MText-Objekt

Transl. "Add the BackgroundFill property to the MText object"

Sebastian

0 Likes
Message 17 of 25

john.uhden
Mentor
Mentor
Interesting.
It works so long as you pick the curve within the limits of the text.

John F. Uhden

0 Likes
Message 18 of 25

john.uhden
Mentor
Mentor

Okay.

But how do you remove the backgroundfill?

I tried...

(FOREACH DXF '(90 43 45 63)(SETQ ENT (VL-REMOVE (ASSOC DXF ENT) ENT)))

(entmod ent)

which changed the entity data, but not the appearance,

even after an (entupd e).

 

John F. Uhden

0 Likes
Message 19 of 25

cadffm
Consultant
Consultant

Far away from ACAD:

Is the result a valid entity list?

I ask because gc43 is not part of the background thing..

 

And sometimes we are in hurry and don't see basic mistakes.

But if your code is correct and it isn't working,

the last option is to create a new object and erase the old one.

 

I will try it in a newer version, if you are not faster with your test.

Sebastian

0 Likes
Message 20 of 25

ronjonp
Mentor
Mentor

@john.uhden wrote:

Okay.

But how do you remove the backgroundfill?

I tried...

(FOREACH DXF '(90 43 45 63)(SETQ ENT (VL-REMOVE (ASSOC DXF ENT) ENT)))

(entmod ent)

which changed the entity data, but not the appearance,

even after an (entupd e).

 


A kludge, but this works here:

(if (setq e (car (entsel)))
  (progn
    (entmake (vl-remove-if '(lambda (x) (vl-position (car x) '(90 45 63 441))) (entget e '("*"))))
    (entdel e)
  )
)

you might take a look at this for a full fledged solution 🙂

0 Likes