AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Member
PuckTheJoker
Posts: 3
Registered: ‎12-04-2012
Message 1 of 10 (554 Views)

Help creating a LISP

554 Views, 9 Replies
12-04-2012 11:36 AM

I'm not sure this is even possible but I was hoping to create a multifunction LISP. I've created simple LISPs in the past but not having any actual training in the language, I'm not sure how to make a LISP for what I want to do.

 

What I'm trying to do is create a LISP that will:
Select All (command "_ai_selall")

Properties (command "Properties")

Choose Rotated Dimensions

Change value of Dim Scale Linear

Change Value of Dim Units

Change Value of Precision

Choose Aligned Dimensions

Change value of Dim Scale Linear

Change Value of Dim Units

Change Value of Precision

Choose Radial Dimensions

Change value of Dim Scale Linear

Change Value of Dim Units

Change Value of Precision

Close Properties (command "Propertiesclose")

Deselect All

 

For all the value changes, I'm only trying to change the value of the selected objects, I'm not trying to change variables for dimsension styles like DIMLUNIT does for example.

 

I'm using AutoCAD 2012 on Windows 7, any help would be much appreciated.

Valued Mentor
bgingerich
Posts: 276
Registered: ‎08-29-2011
Message 2 of 10 (543 Views)

Re: Help creating a LISP

12-04-2012 12:58 PM in reply to: PuckTheJoker

I don't have time (any maybe not the knowledge) to write it for you, however, I can point you to some terms and ways of doing things.  As far as I know most of the LISP users here are self taught too, so don't be afraid to look in 2012's developer documentation and around the internet too.

 

First, for selecting the appropriate objects, you need to create a selection set of them (by what you said in your message, you're going to need 3, one for each type of dimension).  Just search for "selection set" in the forums if you have problems or questions, there are quite a few that deal with selection sets.

 

Second, you're going to be prompting the user for input and storing this input in variables (not system variables which you appear to want to override).

 

There is no need to "select all" of the objects; creating selection sets will eliminate this and the need for the properties palette.

 

(if ("mysolution"=answer) then (click "Accept As Solution"))
------------------------------------------------------------------------------------

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
*Expert Elite*
dbroad
Posts: 1,647
Registered: ‎08-16-2007
Message 3 of 10 (526 Views)

Re: Help creating a LISP

12-05-2012 05:00 AM in reply to: PuckTheJoker

I could be missing the point, but dimensions should be controlled by style, not by override.  Create the styles you want to use and then use dimupdate.

 

Aside:  Strongly suggest that you change your workflow so that changing your linear factor is never necessary.

 

For LISP help post in the customization forum.

*Expert Elite*
pendean
Posts: 23,640
Registered: ‎11-06-2003
Message 4 of 10 (521 Views)

Re: Help creating a LISP

12-05-2012 05:07 AM in reply to: dbroad
Member
PuckTheJoker
Posts: 3
Registered: ‎12-04-2012
Message 5 of 10 (512 Views)

Re: Help creating a LISP

12-05-2012 07:37 AM in reply to: bgingerich

@bgingerich

I'll take a look at selection sets, thanks for the info. As for prompting users for input, I actually want to include a value in the LISP to autochange the values. Let's say before I run the LISP, Dim Scale Linear = 1. After I run the LISP, I want it to automatically change it's value to .03937.

 

@dbroad

Our shop draws in metric, we dimension in metric, we cut in metric, we build in metric, we do everything in metric. However, when we print out a set of drawings for the client, we need to change our dimensions to inches. I could go into each DimStyle and change it there and then update the drawing, but when I'm using anywhere from 5-12 DimStyles on a job, it is much easier to change all the dimensions at once by using the properties override. The whole point of the LISP for me was to have an automated command to change all my dimensions from metric to inches & another LISP to change them from inches to metric.

 

@pendean

Thanks for the link. Should I recreate the thread over in that forum or try to find a mod to move this one? I'm new here so not sure on the protocols as they vary from site to site.

Valued Mentor
bgingerich
Posts: 276
Registered: ‎08-29-2011
Message 6 of 10 (504 Views)

Re: Help creating a LISP

12-05-2012 08:21 AM in reply to: PuckTheJoker

PuckTheJoker wrote:

@bgingerich

I'll take a look at selection sets, thanks for the info. As for prompting users for input, I actually want to include a value in the LISP to autochange the values. Let's say before I run the LISP, Dim Scale Linear = 1. After I run the LISP, I want it to automatically change it's value to .03937.

 

@dbroad

Our shop draws in metric, we dimension in metric, we cut in metric, we build in metric, we do everything in metric. However, when we print out a set of drawings for the client, we need to change our dimensions to inches. ...


Did you know that there is an alternate units option in DIMSTYLE?  You can have your dimensions in your metric standard (cm, mm, etc.) and the alternate units be in inches.  See attached screenshot (inches with mm as alternate unit).

 

And if you really want to change via LISP, yes, post your question in that forum.

 

(if ("mysolution"=answer) then (click "Accept As Solution"))
------------------------------------------------------------------------------------

 

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
*Expert Elite*
hmsilva
Posts: 3,342
Registered: ‎12-17-2004
Message 7 of 10 (479 Views)

Re: Help creating a LISP

12-05-2012 03:50 PM in reply to: PuckTheJoker

PuckTheJoker,

maybe something like this:

 

(defun c:mm2inc (/ ss i ent obj); milimeters to inches
  (if (setq ss (ssget "_x" '((0 . "DIMENSION"))))
    (progn
      (setq i 0)
      (while (setq Ent (ssname ss i))
	(setq obj (vlax-ename->vla-object ent))
	(if (member (vla-get-ObjectName obj)
		    '("AcDbRotatedDimension"
		      "AcDbRadialDimension"
		      "AcDbAlignedDimension"
		     )
	    )
	  (progn
	    (vla-put-UnitsFormat obj 3); change as you need
	    (vla-put-LinearScaleFactor obj (/ 1 25.4))
	    (vla-put-PrimaryUnitsPrecision obj 2) ; change as you need
	    (setq i (+ 1 i))
	  )				;progn
	  (setq i (+ 1 i))
	)				; if
      )					; while
    )					; progn
  )					; if
  (setq ss nil)
  (princ)
)					; defun


(defun c:inc2mm (/ ss i ent obj); inches to milimeters
  (if (setq ss (ssget "_x" '((0 . "DIMENSION"))))
    (progn
      (setq i 0)
      (while (setq Ent (ssname ss i))
	(setq obj (vlax-ename->vla-object ent))
	(if (member (vla-get-ObjectName obj)
		    '("AcDbRotatedDimension"
		      "AcDbRadialDimension"
		      "AcDbAlignedDimension"
		     )
	    )
	  (progn
	    (vla-put-UnitsFormat obj 2)
	    (vla-put-LinearScaleFactor obj 1)
	    (vla-put-PrimaryUnitsPrecision obj 3) ; change as you need
	    (setq i (+ 1 i))
	  )				;progn
	  (setq i (+ 1 i))
	)				; if
      )					; while
    )					; progn
  )					; if
  (setq ss nil)
  (princ)
)					; defun

 

hope that helps

 

Henrique

*Expert Elite*
pendean
Posts: 23,640
Registered: ‎11-06-2003
Message 8 of 10 (462 Views)

Re: Help creating a LISP

12-06-2012 04:48 AM in reply to: PuckTheJoker

I was just offering you another location to seek help if this forum's discussion topic dries up. I think it's safe to simply repost and provide a link to this discussion if you do so.

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
Member
PuckTheJoker
Posts: 3
Registered: ‎12-04-2012
Message 9 of 10 (452 Views)

Re: Help creating a LISP

12-06-2012 07:44 AM in reply to: hmsilva

After changing a couple of the obj numbers, it worked perfectly. Thank you for all of your help, I really appreciate it.

 

I also want to thank everyone else who gave me suggestions, I'm glad to see people who actually try to help others, not flame or troll them for their lack of information.

*Expert Elite*
hmsilva
Posts: 3,342
Registered: ‎12-17-2004
Message 10 of 10 (448 Views)

Re: Help creating a LISP

12-06-2012 07:51 AM in reply to: PuckTheJoker

You're welcome, PuckTheJoker

 

Henrique

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.