Jump to content

Recommended Posts

Posted

Hello,

 

I am very new to LISP programming and finally have an idea for a lisp that would clear up alot of the drawings i work on but i have no idea where to start. I am trying to make something that would select all the dimensions and change the Z value of the text. There seems to be no field for Z position in dimension properties, however when i list a dimension there is a Z position. I want to do this because text displays incorrectly when the Z value is not precisely zero. I do not know how to translate any of this into code. Any info would be great and i would like to try to write this on my own so i can learn the process of writing a routine.

 

 

Thanks in advance!:D

Posted

When I started with in-depth manipulation of an entity, I used (subst), (entmod) and (entupd)

 

Basically, that list you get when you type (entget(car(entsel))) is what AutoCAD recognizes as the entity, and you can modify that list in order to modify the entity.

 

Here's what I used to help me out:

 

http://www.jefferypsanders.com/autolispintr_ent.html

 

He pretty much taught me everything I know, until I found the AutoCAD LISP help file, and this forum.

Posted

There are various ways to approach this - depending on a few things:

 

  • Do you want the LISP to automatically select all dimension text?

  • Do you want the user to select each individual dimension text, or maybe use a window selection method?

  • Do you want to proceed with Visual LISP or plain Vanilla LISP

Let me know how you would like to proceed and I will try to help you in any way that I can :)

 

Lee :)

Posted

I'm curious (Lee)

Using vla-get-Textposition creates a variant, vlax-variant-value makes a safearray, vlax-safearray->list creates a list. You can manipulate this list to create a new list to force Z to zero.

How do you get the new list back to a variant to use vla-put-Textposition?

(or am I approaching this entirely wrong?)

Posted

You are on the right track Larry :)

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:dimtxt  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] dEnt dimObj tPos[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] dEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Dimension: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"DIMENSION"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] dEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   
   [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] dimObj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] dEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b]

   [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tPos [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b]
                [b][color=RED]([/color][/b][b][color=BLUE]vlax-variant-value[/color][/b]
                  [b][color=RED]([/color][/b][b][color=BLUE]vla-get-TextPosition[/color][/b] dimObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

   [b][color=RED]([/color][/b][b][color=BLUE]vla-put-TextPosition[/color][/b] dimObj
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] tPos[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] tPos[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Posted

Upon testing however, this doesn't seem to update the dimension..., :huh::huh:

Posted

Wow thanks for the quick replies! Im going to digest this material over the weekend.

Posted
Upon testing however, this doesn't seem to update the dimension...,

no, but now I know how to make a point list a variant. Thanks

Posted

What are the advantages to using visual lisp over vanilla lisp? Is visual easier to learn?

Posted
What are the advantages to using visual lisp over vanilla lisp? Is visual easier to learn?

 

There is more that you can accomplish using Visual LISP as it permits more access to program structure, whereas Vanilla LISP is not as versatile (and is older).

 

I would say that Vanilla LISP is easier to learn, but Visual LISP is more intuitive when you have gotten to know it for a while. :)

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