Jump to content

Crossing Line Selction & Break the Line Intersect(Selected Line Intersection Automati


Recommended Posts

Guest giscad84
Posted

Hay friends I am John. Now I am doing the Project in Cad. So Iam expect Some Codes (Lsp). Any body helps me for this?(Plz see my 2 helps)

 

1)Here i am SelectingLine_Selection.dwg the Red Color(In Attached Dwg) Line and Give Command means wherever that Red line intersect with another line its should be break(Line means here Line & Polyline and Breakline(Both)).Here I am selecting multi line means also That multi line intersection Should be break. This is my challenge in my project. I want break with only lines (Source)

 

2) What ever entities (Like Block, Circle, Line, and PolyLine) crossing with my Selected line its should be select...

Posted

John,

 

Welcome to the forum,

 

The main focus of the forum is to help people learn to code for themselves. Have you tried yourself?

 

Problem 1) Learn about (inters) function and the BREAK command

 

Problem 2) Learn about (ssget) function

 

-David

Guest giscad84
Posted

I am New for Cad.I have worked with Only ArcGIS.So only i am asking.If you are given this Code means i will try to learn from this codes....So plz help me for this 2 Options.....

Posted

John

 

Your problems are for someone with at least an intermediate level of knowledge of AutoLSIP, not a novice. I'd suggest that you start with basic cad functions and commands, prior to trying to create a fairly involved customization routine. -David

Posted

If you want to throw yourself in the deep end then heres a start it wont work but it is the method to do what you want just pick two points across a group and return the Inters pt and object at that point.

 

;;;   by Alan
;;;   1 April 1992
;;;   
;;;  DESCRIPTION
;;;  AUTOMATICALLY DIMENSIONS 
(setq ppt1 (ENTSEL "\npick first point to dimension :"))
 (setq tpp1 (entget (car ppt1) ) )
(setq npt1 (cadr ppt1))

(setq pt5 (getpoint  "\npick second point to dimension :"))
 
(setq ss (ssget "F" (list npt1 pt5))) ; ss this is the list of crossing objects 

(while (setq en (ssname ss 0)) ; loop now through objects
    (setq dimpt1 (cdr (assoc 10 (entget en))))      
    (setq dimpt2 (cdr (assoc 11 (entget en))))      
    (setq newpt2 (inters pt5 npt1 dimpt1 dimpt2 nil))      
    (if (/= newpt2 nil) 
   (progn 
        (IF (/= NEWPT2 OLDPT)
        (progn
        (setq sss (cons newpt2 sss))
        (SETQ OLDPT NEWPT2)
        )
        )
; CHECK TO SEE IF SAME AS PREV
   )
    )
; Delete each measured entity from set
(ssdel en ss)                   
)                               

 

A couple of other gotcha's when you do the "F" fence across objects it returns the objects not how you see them but rather as they were drawn in the database so you must sort them from the 1st point towards the 2nd point.

Guest balajibth84
Posted
If you want to throw yourself in the deep end then heres a start it wont work but it is the method to do what you want just pick two points across a group and return the Inters pt and object at that point.

 

;;;   by Alan
;;;   1 April 1992
;;;   
;;;  DESCRIPTION
;;;  AUTOMATICALLY DIMENSIONS 
(setq ppt1 (ENTSEL "\npick first point to dimension :"))
 (setq tpp1 (entget (car ppt1) ) )
(setq npt1 (cadr ppt1))

(setq pt5 (getpoint  "\npick second point to dimension :"))
 
(setq ss (ssget "F" (list npt1 pt5))) ; ss this is the list of crossing objects 

(while (setq en (ssname ss 0)) ; loop now through objects
    (setq dimpt1 (cdr (assoc 10 (entget en))))      
    (setq dimpt2 (cdr (assoc 11 (entget en))))      
    (setq newpt2 (inters pt5 npt1 dimpt1 dimpt2 nil))      
    (if (/= newpt2 nil) 
   (progn 
        (IF (/= NEWPT2 OLDPT)
        (progn
        (setq sss (cons newpt2 sss))
        (SETQ OLDPT NEWPT2)
        )
        )
; CHECK TO SEE IF SAME AS PREV
   )
    )
; Delete each measured entity from set
(ssdel en ss)                   
)                               

 

A couple of other gotcha's when you do the "F" fence across objects it returns the objects not how you see them but rather as they were drawn in the database so you must sort them from the 1st point towards the 2nd point.

 

 

 

This Code for dim..i am asking for What ever entities am selecting that line Selected line touched entyties (Like Block, Circle, Line, and PolyLine) need to selected should be select...

Guest balajibth84
Posted

Dear All Plz chk the Code for Advance Selection..See #1 my 2) point

 

****(defun c:AS (/) (c:SelectEverythingTouching))

(defun c:SelectEverythingTouching (/ *error* #SS #P1 #P2 #Temp #Add #Num)

(defun *error* (#Message)

(and #Message

(not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))

(princ (strcat "\nError: " #Message))

) ;_ and

) ;_ defun

(vl-load-com)

(cond

((setq #SS (ssget))

(or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))

(setq #Add (ssadd))

(vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))

(vla-getboundingbox x '#P1 '#P2)

(setq #P1 (vlax-safearray->list #P1)

#P2 (vlax-safearray->list #P2)

) ;_ setq

(and (setq #Temp (ssget "_C"

(trans (list (car #P1) (cadr #P2) 0.) 0 1)

(trans (list (car #P2) (cadr #P1) 0.) 0 1)

) ;_ ssget

) ;_ setq

(repeat (setq #Num (sslength #Temp))

(if (vlax-invoke

x

'IntersectWith

(vlax-ename->vla-object (ssname #Temp (setq #Num (1- #Num))))

acExtendNone

) ;_ vlax-invoke

(ssadd (ssname #Temp #Num) #Add)

T

) ;_ if

) ;_ repeat

(ssadd (vlax-vla-object->ename x) #Add)

) ;_ and

) ;_ vlax-for

(vla-delete #SS)

(sssetfirst nil #Add)

)

) ;_ cond

(princ)

) ;_ defun

****

Posted

something for you to run with...

 
(defun c:test  (/ p1 p2 ss id ent)
 (setq p1 (getpoint "\nSpecify first point: ")
p2 (getpoint p1 "\nSpecify second point: "))
 (if (eq (setq ss (ssget "F" (list p1 p2) '((0 . "line")))) nil)
  (prompt "\nNo lines found!")
  (repeat (setq id (sslength ss))
    (setq ent (entget (ssname ss (setq id (1- id)))))
    (entmakex
      (list
 (cons 0 "point")
 (cons 10 (inters p1 p2 (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
             )
    )
  )
 )
 (princ)
)

Posted
Dear All Plz chk the Code for Advance Selection..See #1 my 2) point

 

Didn't I ask you to put your code in quote tags?

Yes, I did. 5 times! I feel like I'm talking to a brick wall.

Please refer to the PM I sent you previously, AGAIN!!! :roll:

 

Where's the banging head smiley?

Posted

Actually, I'd like to know why he feels it acceptable to post code that is not his and in doing so, has completely stripped my information from the code?

Seriously? You post over at theSwamp, I shoot you a link and you just rip off my code?

Your link wanting help: http://www.theswamp.org/index.php?topic=1892.0

A link to my code: http://www.theswamp.org/index.php?topic=32430.0

 

I don't know who's the bigger idiot here; me for being nice enough to help you or you for thinking I was stupid enough not to realize you hacked out my name and copyright notices from my own code. The really annoying thing is, in my notice, I give you all editing and posting rights, with the only stipulation being that you leave all notices IN TACT!

 

Excessive abuse of forum, posting under two usernames (the other of which was banned), badgering within threads to just post some code and now, thievery. You're off to a great start in these forums.

 

Seriously though, please remove the code you posted.

Posted

Where's the banging head smiley?

 

It's deja vu all over again.

 

We may have to bang on the head of the person in question. Gentlemen...grab your hammers. It's head bangin time!

Posted

bala: You owe the man (Alan) his props and a really big apology dude! Then someone should kick your gluteus maximus back to where it came from, pronto, just because you thought you could get away with it. Shame on you.

Posted (edited)
Dear All Plz chk the Code for Advance Selection..See #1 my 2) point

 

****(defun c:AS (/) (c:SelectEverythingTouching))

(defun c:SelectEverythingTouching (/ *error* #SS #P1 #P2 #Temp #Add #Num)

(defun *error* (#Message)

(and #Message

(not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))

(princ (strcat "\nError: " #Message))

) ;_ and

) ;_ defun

(vl-load-com)

(cond

((setq #SS (ssget))

(or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))

(setq #Add (ssadd))

(vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))

(vla-getboundingbox x '#P1 '#P2)

(setq #P1 (vlax-safearray->list #P1)

#P2 (vlax-safearray->list #P2)

) ;_ setq

(and (setq #Temp (ssget "_C"

(trans (list (car #P1) (cadr #P2) 0.) 0 1)

(trans (list (car #P2) (cadr #P1) 0.) 0 1)

) ;_ ssget

) ;_ setq

(repeat (setq #Num (sslength #Temp))

(if (vlax-invoke

x

'IntersectWith

(vlax-ename->vla-object (ssname #Temp (setq #Num (1- #Num))))

acExtendNone

) ;_ vlax-invoke

(ssadd (ssname #Temp #Num) #Add)

T

) ;_ if

) ;_ repeat

(ssadd (vlax-vla-object->ename x) #Add)

) ;_ and

) ;_ vlax-for

(vla-delete #SS)

(sssetfirst nil #Add)

)

) ;_ cond

(princ)

) ;_ defun

****

Let's compare...

 

;;; ------------------------------------------------------------------------
;;;    SelectEverythingTouching.lsp v1.0
;;;
;;;    Copyright© 03.06.10
;;;    Alan J. Thompson (alanjt)
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    The following program(s) are provided "as is" and with all faults.
;;;    Alan J. Thompson DOES NOT warrant that the operation of the program(s)
;;;    will be uninterrupted and/or error free.
;;;
;;;    Allows user to select all object(s) touching selected object(s).
;;;
;;;    Revision History:
;;;
;;; ------------------------------------------------------------------------

(defun c:SET (/) (c:SelectEverythingTouching))
(defun c:SelectEverythingTouching (/ *error* #SS #P1 #P2 #Temp #Add #Num)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; error handler
 (defun *error* (#Message)
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (vl-load-com)

 (cond
   ((setq #SS (ssget))
    (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
    (setq #Add (ssadd))
    (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))
      (vla-getboundingbox x '#P1 '#P2)
      (setq #P1 (vlax-safearray->list #P1)
            #P2 (vlax-safearray->list #P2)
      ) ;_ setq
      (and (setq #Temp (ssget "_C"
                              (trans (list (car #P1) (cadr #P2) 0.) 0 1)
                              (trans (list (car #P2) (cadr #P1) 0.) 0 1)
                       ) ;_ ssget
           ) ;_ setq
           (repeat (setq #Num (sslength #Temp))
             (if (vlax-invoke
                   x
                   'IntersectWith
                   (vlax-ename->vla-object (ssname #Temp (setq #Num (1- #Num))))
                   acExtendNone
                 ) ;_ vlax-invoke
               (ssadd (ssname #Temp #Num) #Add)
               T
             ) ;_ if
           ) ;_ repeat

           (ssadd (vlax-vla-object->ename x) #Add)
      ) ;_ and
    ) ;_ vlax-for
    (vla-delete #SS)
    (sssetfirst nil #Add)
   )
 ) ;_ cond
 (princ)
) ;_ defun

Edited by alanjt
Posted
Actually, I'd like to know why he feels it acceptable to post code that is not his and in doing so, has completely stripped my information from the code?

 

Excessive abuse of forum, posting under two usernames (the other of which was banned), badgering within threads to just post some code and now, thievery.

 

At this point, I feel like just banning him for all the trouble he's caused, but I would really like to hear his explanation about why he stripped out the header on the file you gave him which clearly states what he is allowed to do with your code.

 

I would also like to hear an apology for the disrespect he's shown to the members of this forum who have gone far out of their way to help him.

Posted

Between this guy and digger, it's as if some other forum hired these guys to pi$s everyone off enough to force them to leave.

Posted

I would hope that other AutoCAD-related Help sites would not encourage or condone such behavior. I think this guy should be banned at both sites but it is not up to me obviously.

  • 4 years later...
Posted

Whoa, I guess I'm not going to find what I wanted.. :oops:

 

I say, ban him, if it already hasn't been done in the last 5 years. :D

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