Jump to content

Test line relations depending on layer


lastknownuser

Recommended Posts

Need help with line relations. I attached a photo of example of final result I need.
White lines are in layer1 and red in layer2. I need lisp to add text to each point between lines depending on the layer. Lines on layer1 get symbol M, on layer2 Z. That I managed to do, but I can't figure out how to add symbol M-Z on point where lines from layer1 and layer2 are connected.

I tried with 3 ssget functions: points, lines from layer1 and lines from layer3. And then nested while that compares points and stard/end of lines, if the same then add symbol M or Z.
Any idea about how to test the condition to get M-Z on point where white and red lines are connected?

 

testt3.png

Edited by lastknownuser
Link to comment
Share on other sites

On 10/14/2021 at 9:31 AM, lastknownuser said:

I tried with 3 ssget functions: points, lines from layer1 and lines from layer3. And then nested while that compares points and stard/end of lines, if the same then add symbol M or Z.
Any idea about how to test the condition to get M-Z on point where white and red lines are connected?

 

Your on the right path with this. except I would do it a bit different. just create all the M and Z text like normal but add them to SS3 as you go

(ssadd SS3 (entlast))

 

Then once all the text are created compare them to each other if the have the same point set that to a variable then delete both text and use that point to create M-Z text.

(defun C:Foo (/ SS3 tlst pt)
  (setq SS3 (ssget '((0 . "TEXT") '(410 . "Model")))) ;this is for my testing.
  (setq tlst (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS3))))
  (setq tlst (vl-sort tlst '(lambda (a b) (if (equal (assoc 10 (entget a)) (assoc 10 (entget b)) 1e-6)
                                      (progn
                                        (setq pt (assoc 10 (entget a)))
                                        (entdel a)
                                        (entdel b)
                                        (vl-cmdf "_.Text" pt "" "" "M-Z")
                                      )
                                    )
                            )
             )
  )
  (princ)
)

 

looks like your creating text with bottom left so thats 10 but if its something else you need to use 11.

 

  • Like 1
Link to comment
Share on other sites

Another is intersectwith  and get the int points. If white is considered "outside" then red is "inside" so dont label 1st and last of inside. Then update text at "ints". 

Link to comment
Share on other sites

There are a couple of ways to use it

 

(setq obj1(vlax-ename->vla-object (car  (entsel "Pick obj"))))
(setq obj2 (vlax-ename->vla-object (car  (entsel "Pick obj"))))

(setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))

 

Have a go and if you get stuck just post what you tried to use.

Edited by BIGAL
Link to comment
Share on other sites

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