Jump to content

Lisp for Dimension divided by spacing


Recommended Posts

Posted

Hello friends,

I need lisp for Numbers from Dimension divided by Spacing

(Ex. 1000/200=5). Here 1000 will be Length, 200 will be spacing and 5 will be Numbers.Number value would be change If we change dimension length (Increase/Decrease). Please refer below sketch...

 

[ATTACH]30204[/ATTACH]

Posted

How do you get the 200 or the 5? Do you type it in that way through DDEDIT?

 

Perhaps you can get it right using fields. See the attached DWG. It's got 2 sets of dimensions which have fields linking to each other. The dims below are set with a DimLFac of 200.0 which is used as the C/C distance - and can be changed through the properties palette. If you want it as the number of divisions then the fields would be similar, but the math would differ a bit.

 

To have it update do a regen.

Test Dim.dwg

Posted

Thanks for the replay..

We are doing Structural rebar detailing. In this case, 1000 will be the length(mm), 200 will be bar spacing & 5 will total bars in 1000 length i.e 1000/200=5.

 

Yes..I have given DDEDIT command to put " [5] or @ 200C/C" as a text.

 

But we need lisp for Numbers(5) and Spacing (200) divided from Total length(1000) (AutoCAD Entity like dimension or lisp). Numbers shall be automatically change If we change the dimension length (1000 to 1500) (or) spacing (200 to 150).

 

In your cad file, i couldn't see the changes because its like text only..not linking to each other. Please give me solution...

Posted

I am not sure that you are going to end up with the correct number of bars.

 

If you have a length of 1000mm and a spacing of 200mm, then you need 6 bars. :shock:

Posted
In your cad file, i couldn't see the changes because its like text only..not linking to each other. Please give me solution...
As I've stated it needs a regen (like all field codes always do). After stretching both dimensions issue the REGEN command to update the fields.

 

If you have a length of 1000mm and a spacing of 200mm, then you need 6 bars. :shock:
That's probably true. Similar to when I do a stair section (i.e. 12 treads but 13 risers ;)). The idea is in the fields of my previous attachment, the details about how you want to work it out is up to you.
Posted (edited)

Thanks friend... Its good but I don't want to change above dimension entity which is 1000 (This one not needed)....

I want to change in same dimension length which are mentioned "[5] @ 200 c/c"

 

And then how to change spacing from 200 to 150 (or) 125? and also I need to be add 1 No. constantly. ie. 1000/200=5+1=6 Nos.

 

Number value to be round up If fraction value comes ie. 1100/150=7.33+1=9..Please give me solution friend...

Edited by rajeshmuthu
Posted

Select that dimension showing the @ 200. Open properties palette (Ctrl+1), then (under the "Primary units" group) change the "Dim scale linear" from 200 to 150, or 125, or whatever else you want. You can apply the change to more than one dim at a time as well, simply select those you want to change and make the change once in the palette.. Then do another regen :thumbsup:.

 

As for adding 1+. DDedit that dim, then double click on the #### to open the field dialog. You'll see it's simply a formula.

Posted

Anyhow, if you want it as a lisp:

(defun c:@Dims (/ dist ss n eo)
 (if (and (setq dist (getdist "\nSpecify increment distance: "))
          (setq ss (ssget '((0 . "DIMENSION"))))
     )
   (progn
     (setq n (sslength ss))
     (while (> (setq n (1- n)) -1)
       (setq eo (vlax-ename->vla-object (ssname ss n)))
       (vla-put-AltUnitsScale eo dist)
       (vla-put-LinearScaleFactor eo (/ 1.0 dist))
       (vla-put-TextOverride
         eo
         (strcat "[%<\\AcExpr (1+%<\\AcObjProp Object(%<\\_ObjId "
                 (itoa (vla-get-ObjectID eo))
                 ">%).Measurement \\f \"%lu2%pr0\">%) \\f \"%lu2%pr0\">%]\\X@ %<\\AcObjProp Object(%<\\_ObjId "
                 (itoa (vla-get-ObjectID eo))
                 ">%).AltUnitsScale \\f \"%lu2%pr0\">% C/C"
         )
       )
       (vla-Update eo)
     )
   )
 )
 (command "._UpdateField" ss "")
 (princ)
)

Posted

Wow...Superb....Thanks a lot friend....This one i want...

Posted

Hi irneb,

Instead of (command updatefield ss "")

 

 

try

(defun ad nil
 (setq *acdoc*
   (cond  ( *acdoc* )
     ( (vlax-get (vlax-get-acad-object)
         'ActiveDocument
       )
     ) 
   )
 )
)

[b][u][color=darkred](vla-regen (ad) acactiveviewport)[/color][/u][/b]

  • 1 year later...
Posted

Hi Guys,

 

Looking at the lisp above its very similar to one that i was also looking for, albeit where rajeshmuthu wanted to add a bar at the end, as irneb noted, we just simply need the dimension dividing by a set distance (say 3000mm for example).

 

So if we have a dimension of 600mm we have 1 No 3000mm length, 6050 we have 3 No 3000mm lengths, etc, but also leave the orginal dim in the dimension line.

 

Apart from the additonal bit of "wish list" for the majority of cases the lisp seems to work fine, however, if you look at the example below for some reason I get the odd one which is incorrect see both dims @ 17000 and 17495??

 

Any suggestions would be appreciated.

MERC0007.jpg

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