Entmod to trim two lines

Discussion in 'AutoCAD' started by JFields, Dec 28, 2004.

  1. JFields

    JFields Guest

    I am trying to write a routine to make duct transitions and I want it to trim the two lines of the original duct using entmod. What I have so far works only for lines drawing horizontal and vertical but not in between. If I run the routine on ducts drawn at any other angle it doesn't trim from the correct points. Here is part of the program:

    (setq p1 (getpoint "\nPick left side of duct: "))
    (setvar "OSMODE" 128) ;PERP
    (setq p2 (getpoint p1 "\nPick right side of duct (PERP): "))
    (setvar "OSMODE" 0) ;NONE
    (setq dist1 (distance p1 p2))
    (setq ent1 (ssname (ssget p1) 0)
    ent2 (ssname (ssget p2) 0))
    (setq duct1 (entget ent1)
    duct2 (entget ent2))
    (setq objlayer (cdr (assoc 8 (entget ent1))))
    (command "layer" "s" objlayer "")
    (setq defang 15.0)
    (setq ang1 (getreal (strcat "\nEnter LEFT taper angle (" (rtos defang 2) "): ")))
    (if (null ang1) (setq ang1 defang))
    (setq ang2 (getreal (strcat "\nEnter RIGHT taper angle (" (rtos defang 2) "): ")))
    (if (null ang2) (setq ang2 defang))
    (command "line" p1 p2 "")
    (setq orient (- (angle p2 p1) (/ pi 2)))
    (setq pt1 (cdr (assoc 10 duct1))
    pt2 (cdr (assoc 11 duct1))
    pt3 (cdr (assoc 10 duct2))
    pt4 (cdr (assoc 11 duct2))
    )
    (if (= (angle p1 pt1) orient)
    (entmod (subst (cons 10 p1) (cons 10 pt1) duct1))
    (entmod (subst (cons 11 p1) (cons 11 pt2) duct1))
    )

    (if (= (angle p2 pt3) orient)
    (entmod (subst (cons 10 p2) (cons 10 pt3) duct2))
    (entmod (subst (cons 11 p2) (cons 11 pt4) duct2))
    )

    I think the problem is my choice of using an if to find the point of the line that is in the direction of the desired transition. The last two if statements are where I need help. Any suggestions or ideas on what I could do to fix this problem would be greatly appreciated.

    Thanks,
    Joe Fields
     
    JFields, Dec 28, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.