Results 1 to 9 of 9

Thread: Need help with trimming.

  1. #1
    Active Member
    Join Date
    2009-11
    Location
    North Texas
    Posts
    55
    Login to Give a bone
    0

    Default Need help with trimming.

    Hello,

    To start off, I just wanted to say I've only been using AutoCad for about a year, and AutoLisp for a few months so I apologize if I don't understand something.

    Anyways,

    I am trying to write a lisp program to draw some doors. I've been able to draw doors with square tops, but I just started trying to get tops with radius' working. My problem comes when I am offsetting the top radius for the glass bead, and then the panel profile. Basically I am offsetting the origional radius by 5/8 and then 2 inches. After the lines are offset, I need to trim the ends of them so they meet with the vertical lines. I'm able to select the lines for offsetting, but I can't figure out how to pick the small side of the radius that needs to be trimmed off. The only known point I have is the top center of my radius.

    Maybe I'm doing this completely wrong though, please help.

    Thanks.


    Also, keep in mind, there needs to be no pauses for user interaction after the origional specs are entered. Once the door starts drawing it needs to draw all the way through.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    Can you post some of what you have? It reduces the need to reinvent the wheel.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Active Member
    Join Date
    2009-11
    Location
    North Texas
    Posts
    55
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    I'll post my .lsp

    If you run it, and have it sitting in front of you it might be easier to understand me.. Unfortunately I deleted the 2nd draft I did, beacuse I couldn't get it to work.

    If you look at the top of the door after you run it you will see 3 radii near the top. The distance between the arcs are supposed to be constant. So if I were drafting this in AutoCad without using Lisp, I would just use the offset tool from the top most arc, offsetting down .625, and 2. So if you create the door with my .lsp and do those 2 offsets, you will see that the lines then need to be trimmed to match the vertical lines, and I just don't know how to do that in lisp =/

    Again, I apologize if my code is bizzare, and/or doing things the hard way, I just took the tools I knew and went to town.

    I guess I should mention, when entering values prompted at the command prompt, use 36 for Width, 96 for Height, 6 for Stiles, and then 5 for number of Vgrooves. It should work with any values... assuming you put in number that are somewhat normal for a door =)
    Attached Files Attached Files
    Last edited by d.m.polsky; 2009-11-18 at 12:48 AM. Reason: Typos

  4. #4
    Active Member
    Join Date
    2008-06
    Location
    Australia
    Posts
    51
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    Your mitre to the arc at the top is drawn at 45 degrees which is incorrect. This is causing the arcs to be not spaced evenly. If you work out the centre point of the arc and use that to locate points for the mitre it should work out ok.

    I avoid using trim, extend etc whenever possible as the selection is often difficult to control.

    Steve

  5. #5
    Active Member
    Join Date
    2009-11
    Location
    North Texas
    Posts
    55
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    I know, that is where I'm getting stuck.

    How can I find my two end points?

    I know my top quadrant for each offset and that is about it. Is there some crazy triangle or circle forumla that I should be using here?

  6. #6
    Active Member
    Join Date
    2008-06
    Location
    Australia
    Posts
    51
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    After drawing the first arc you can get the centre point and radius with

    (setq arc_cen (cdr (assoc 10 (entget (entlast))))) ; centre point
    (setq arc_rad (cdr (assoc 40 (entget (entlast))))) ; radius

    Then you can use basic trig to calculate the endpoints for the other arcs.

    Steve

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    Quote Originally Posted by d.m.polsky View Post
    I know, that is where I'm getting stuck.

    How can I find my two end points?

    I know my top quadrant for each offset and that is about it. Is there some crazy triangle or circle forumla that I should be using here?
    You can find this information with the Visual LISP functions for curves. Of course, you can use those functions on more than just curves. Then again, you will need to convert the entities to vla objects. I have something at the office. If I have time later, I'll try to throw something together for you to dissect.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  8. #8
    Active Member
    Join Date
    2009-11
    Location
    North Texas
    Posts
    55
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    Quote Originally Posted by steve.ashton View Post
    After drawing the first arc you can get the centre point and radius with

    (setq arc_cen (cdr (assoc 10 (entget (entlast))))) ; centre point
    (setq arc_rad (cdr (assoc 40 (entget (entlast))))) ; radius

    Then you can use basic trig to calculate the endpoints for the other arcs.

    Steve
    This seems a little over my head. I've got a Visual Lisp book (green one) I'm going to see if I can figure out all the elements you have there. If not I will let you know.

    Thanks

  9. #9
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Need help with trimming.

    A few things you need to look into in the future. Localize your variables; saving & restoring system variables you modify in your code; and use less cryptic variable names.

    Now to your code. I didn't do much other than adjusting the corners of your arcs at the top of your door.
    Add these two functions to either within your routine (and localize their names) or add them to your toolbox (you may need them in the future).
    Code:
    (defun getCurveIntersection (objCurve 3DPoint lstVector /) ;_ No variables to localize for this routine
        (if	(= (type objCurve) 'ENAME) ;_ Check if value from the arguement objCurve is an entity and not a vla-object
          (setq objCurve (vlax-ename->vla-object objCurve)) ;_ Convert to vla-object
        )
        (if	(= (type objCurve) 'VLA-OBJECT) ;_ verify we are dealing with a vla-object
          (vlax-curve-getClosestPointToProjection
    	objCurve
    	3DPoint
    	lstVector
          ) ;_ get 3D point of projection
          nil ;_ return nil if not working with a vla-object
        )
      )
    Code:
    (defun setCurveAngles	(objCurve pntStart pntEnd /) ;_ No variables to localize for this routine
        (if	(= (type objCurve) 'ENAME) ;_ Check if value from the arguement objCurve is an entity and not a vla-object
          (setq objCurve (vlax-ename->vla-object objCurve)) ;_ convert to vla-object
        )
        (if	(= (type objCurve) 'VLA-OBJECT) ;_ verify we are dealing with a vla-object
          (progn
    	(vla-put-StartAngle ;_ adjust start angle of arc
    	  objCurve
    	  (angle (vlax-safearray->list
    		   (vlax-variant-value (vla-get-center objCurve))
    		 )
    		 pntStart
    	  )
    	)
    	(vla-put-EndAngle ;_ adjust end angle of arc
    	  objCurve
    	  (angle (vlax-safearray->list
    		   (vlax-variant-value (vla-get-center objCurve))
    		 )
    		 pntEnd
    	  )
    	)
          )
          nil ;_return nil if not working with vla-object
        )
      )
    Now that you have these two functions, after you draw your first arc add this code:
    Code:
      (setq entArcOuter (entlast))
      (command "offset" 2.0 entArcOuter tamm2 "")
      (setq entArcInner (entlast))
      (command "offset" 0.625 entArcOuter tamm "")
      (setq entArcMiddle (entlast))
    
      (setq tamb (setq pntLeftMiddleArc (getCurveIntersection entArcMiddle tamb '(0.0 1.0 0.0)))
    	tdmb (setq pntRightMiddleArc (getCurveIntersection entArcMiddle tdmb '(0.0 1.0 0.0)))
    	tamc (setq pntLeftInnerArc (getCurveIntersection entArcInner tamc '(0.0 1.0 0.0)))
    	tdmc (setq pntRightInnerArc (getCurveIntersection entArcInner tdmc '(0.0 1.0 0.0)))
      )
      (setCurveAngles entArcMiddle pntRightMiddleArc pntLeftMiddleArc)
      (setCurveAngles entArcInner pntRightInnerArc pntLeftInnerArc)
    You can also remove the extra double quotes at the end of your code to draw an arc. There is no need for it.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. Trimming
    By Cadventurer in forum AutoCAD General
    Replies: 13
    Last Post: 2008-10-25, 10:48 AM
  2. Trimming
    By shg in forum AutoCAD General
    Replies: 5
    Last Post: 2008-03-04, 04:30 PM
  3. Improvement to Fillet & Chamfer trimming/no trimming options
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-07-12, 03:00 PM
  4. is there a advanced way of trimming?
    By sairahcazj in forum AutoLISP
    Replies: 4
    Last Post: 2005-01-03, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •