Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Motion with dimensional constraint

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
1191 Views, 13 Replies

Motion with dimensional constraint

Is it possible to make a Lisp program to move a mechanism by a dimensional constraint?

 

Jan.

13 REPLIES 13
Message 2 of 14
diagodose2009
in reply to: Anonymous

Hello
Please the file readme.txt
IF ,if,if,if,,,,,,,,,,,it is noooooooooot possible in the language LISP,/Visual C++ObjectARX but we can draw fast and automatic the drawing file in GrdrAw screen 

 

 

 

Edited by
Discussion_Admin

Message 3 of 14
Anonymous
in reply to: diagodose2009

I think, I mean something different.

When I change the value of the dimensional constraint d6 (with  TEXTEDIT or PARAMETERS)

the piston moves.

 

Jan.

 

PS Mechanisms for a can crusher are welcome.

Message 4 of 14
Anonymous
in reply to: Anonymous

Something like this!

 

Jan.

 

PS Mechanisms for a 'can crusher' are welcome.

Message 5 of 14
stevor
in reply to: Anonymous

Since your lsp implies that you are assigning values to a dimension to define the location of the piston, you can use a similar routine to simply MOVE that piston object in the same sequence. And use associative dimensioning to show the changing dimensions, which is only one, if linear. Same for the drive linkage. Not as elegant as the various parametric CADs, but workable.
S
Message 6 of 14
Anonymous
in reply to: Anonymous

Test HofDriven.lsp for AutoLisp kinematics with a driven dimensional constraint!

 

1) Open a drawing from DrivenDwgs.zip for example Piston&Spring.dwg

2) Load the program HofDriven.lsp.

3) Read in the Layout 'Info for HofDriven' the preferable settings.

4) Give in Modelspace the command DRIVEN.

5) Give in your settings and click on OK.

6) Select the driven dimensional constraint.

7) See the moving mechanical components and enjoy.

 

Regards, HofCAD CSI.

Message 7 of 14
Anonymous
in reply to: stevor

Thanks Stevor and Hofcad,

 

Sorry Stevor I don't understand your method, can you give an example of an program?

 

Hofcad your program HofDriven.lsp and the example drawings are great!Smiley Very Happy

Your program is very general and can be applied for Oscillating and Rotating movement.

The command Driven can also applied on my driven dimension d6 in MyPiston.dwg.

It is really fantastic, amazing, awesome and Wow!

 

Jan.

 

PS Mechanisms for a 'can crusher' are welcome.

Message 8 of 14
stevor
in reply to: Anonymous

 

Here is some code to 'MOVE' an object in a linear cyclic stepwise motion.

 

Unlike the constraint dimension method, the move object is selected.

The track points, and a distance confirmation, are included, but they can be omitted if some appropriate data is substituted.

 

 (princ " c:PM ") (textscr)
 
 ; Distance w default real, engr 2 place, on UCS
 (DeFun get_dr  ( dd ps ri / ans )
  (setq ps (if (str_p ps)  ps  " Pick 2 pts / Enter Distance ") )
  (setq dd (if (and dd (numberp dd) ) dd 1.0 ) )
  (setq ans (getdist (strcat " " ps " < "
      (rtos dd 2 ri ) " > ")))  (if ans ans dd) )


 ; simple
 (Defun c:Pm  (/ ) (graphscr)
  (setq cemv (getvar 'cmdecho))  (setvar "cmdecho" 0 )
  (setq osmv (getvar 'osmode))  (setvar "osmode" 0 )
  (setq ormv (getvar 'orthomode)) (setvar "orthomode" 0 )
  (or ;;(and pes sptd (i_yn " Bypass " t))
      (and (setq pes (entsel " Sel Piston "))
           (setq pen (car pes))
           ; (setq psp '(0 0)  pep '(70 0)) ; hard coded
           (setq psp (cadr pes))
           (or (setvar "osmode" 1) (princ" OSnap: End ")t)
           (SETQ psp (getpoint " Start Pt ") )
           (or (setvar "orthomode" 1) t)
           (SETQ pep (getpoint psp " End Pt - Ortho ") )
           (setq ptdp (distance psp pep))  ; throw by pts
           (setq sptd (if sptd sptd ptdp) )
           (setq sptd (get_dr sptd (strcat
            " Move Distance, Pts: " (rtos ptdp 2 2) " " ) 2))  ; throw by dist
      )
      (AND (PRINC " nYET ") (EXIT) )
  )
  ;
  (setvar "osmode" 0 ) (setvar "orthomode" 0 )
  (setq cq  (if cq cq 5)   ; cycles

           sq (if sq sq 10)  ; steps per half cycle
          sdt (if sdt sdt 100)  ) ; step delay time, ms
  (setq ra  (angle psp pep)  rp psp  np rp ; ini
        dps (/ sptd sq 1.0)  dpd 0 ) ; dist per step    
  ;
  (repeat   cq
    (repeat  sq
      (setq dpd (+ dpd dps)   pnp np
            np (polar rp ra dpd) ) ; next pt
      (command "move" pen ""  pnp np )
      (command "_.DELAY" sdt)
    ) ;
    (repeat  sq
      (setq dpd (- dpd dps)  pnp np
            np (polar rp ra dpd) ) ; next pt
      (command "move" pen ""  pnp np )
      (command "_.DELAY" sdt)
    )       
  )
  (setvar 'cmdecho cem ) (setvar "osmode" osm )
  (setvar "orthomode" orm )(princ) )

S
Message 9 of 14
Anonymous
in reply to: stevor

Stevor,

 

Thanks, but I get an error.

error: no function definition: STR_P

 

I don't think that your program is working at my drawing MyPiston.dwg,

because the drawing is fully constrained.

I don't no, how I can relax the d6 dimensional constraint in Lisp.

 

Jan.

Message 10 of 14
Anonymous
in reply to: Anonymous

Because the dimensional constraint d6 is erased in MyPiston2.dwg, you get a Single Degree-of-Freedom(SDOF).
Then you can use:

(Defun c:Piston2 (/ CMD Ent Pstart Pend Steps Cycles AngDec StepSize StepPos
    StepNeg)
  (setq CMD (getvar 'CMDECHO))
  (command "_.UNDO" "_M")
  (setvar "CMDECHO" 0)
  (While (not Ent)
    (setq Ent
    (car (entsel "\nSelect the piston:\n"))
    )
  )
  (setvar 'DYNCONSTRAINTDISPLAY 0)
  ;;In AutoCAD 2011 also (command "_.DCDISPLAY" "_ALL" "_H")
  (setq Pstart (getpoint "\nSelect start point from piston: "))
  (setq Pend (getpoint Pstart "\nSelect end point from piston: "))
  (setq Steps (getint "\nTotal steps: "))
  (setq Cycles (getint "\nTotal cycles: "))
  (setq AngDec  (/ (* (angle Pstart Pend) 180) pi)
 StepSize (/ (distance Pstart Pend) Steps)
 StepPos  (strcat "@" (rtos Stepsize 2 14) "<" (rtos AngDec 2 14))
 StepNeg  (strcat "@"
    (rtos StepSize 2 14)
    "<"
    (rtos (+ AngDec 180) 2 14)
   )
  )
  (repeat Cycles
    (repeat Steps
      (command "_.MOVE" Ent "" "@" StepPos)
      (command "_.DELAY" 100)
    )
    (repeat Steps
      (command "_.MOVE" Ent "" "@" StepNeg)
      (command "_.DELAY" 100)
    )
  )
  (setvar 'DYNCONSTRAINTDISPLAY 1)
  ;;In AutoCAD 2011 also (command "_.DCDISPLAY" "_ALL" "_S")
  (setvar 'CMDECHO CMD)
  (princ)
)

Jan.

PS1 I think that there is no solution in that way
        for the drawing Piston&Spring.dwg(See: Message 6).

PS2 In AutoCAD 2010 you can not use:
    (command "_.DCDISPLAY" "_ALL" "_S")
    You must use:
    (setvar 'DYNCONSTRAINTDISPLAY 1)

Message 11 of 14
stevor
in reply to: Anonymous

Sorry, freeware...

 

 ; STR_P  STRing-Proof
 (defun STR_P (S) (and s (= 'STR (type s))  ))

Hopefully no other subrs are used; most of my SUBRs at at AusCadd.com, on the second page,  linked at bottom of the first:

http://auscadd.com/free-lsp-1.html.

 

Again, this method uses the old MOVE command, not the Constraints approach.

 

Plus, my guess is that you would remove that section and hard code your values; eg, steps, distances, direction.

S
Message 12 of 14
Anonymous
in reply to: stevor

Thanks Stevor,

 

Now I can run your program.

I had to changed tree variables for resetting CMDECHO, ORTHOMODE and OSMODE.

 

  (setvar 'cmdecho cem ) (setvar "osmode" osm )
  (setvar "orthomode" orm )(princ) )

changed to:

  (setvar 'cmdecho cemv ) (setvar "osmode" osmv)
  (setvar "orthomode" orm v)(princ) )

 

Jan.

 

PS Mechanisms for a 'can crusher' are welcome.

Message 13 of 14
stevor
in reply to: Anonymous

Change away. that's when much of the new program features originate.

 

Mechanism keywords:

 

 Linear screw  Actuator, easy to apply, requires torque sensing and reverse, as do most.

 

  Crank drive: you can apply trig to show relative speeds of piston, and increases force when bottoming, cheap surplus gearboxes available.

.

  Sissor drive, or lever variants: simpler construction than a crank, can be of increasing force, cheapest implementation.

 

  Air or hydraulic: least parts, except for compressor, or pumps,etc.

 

Motions:  all  can be simulated in CAD, witht a little trig.

 

S
Message 14 of 14
Anonymous
in reply to: Anonymous

Sorry Stevor I don't understand your method, can you give an example of an program?

 

Jan,

 

See in the attachment there is an oldie!

 

HofCAD CSI

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost