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

setting DIMLFAC

22 REPLIES 22
Reply
Message 1 of 23
knlooi
2699 Views, 22 Replies

setting DIMLFAC

Help! How to make a program that use DIMLFAC to change the dimensions according to the selected object scale factor (change selected dimension only)

22 REPLIES 22
Message 2 of 23
pbejse
in reply to: knlooi


@knlooi wrote:

Help! How to make a program that use DIMLFAC to change the dimensions according to the selected object scale factor (change selected dimension only)


Whats the deal with the attached lisp? You want to modify that to do what you requesting?

 

With the way you phrased your question Its seems simple enough. but why not:use :

Command: Dim

DIM: update

Select Objects:

 

 

Message 3 of 23
knlooi
in reply to: knlooi

here have error << (command "_DIMLFAC" (scale) "" (acadsset ssetobj)) >>

Drawing prompt me input value:

Specify scale factor or [Copy/Reference] <5.000>: 0.262809917355372

Command: _DIMLFAC
Enter new value for DIMLFAC <1.0000>: ; error: bad function: 3.42453
Enter new value for DIMLFAC <1.0000>:

Message 4 of 23
knlooi
in reply to: knlooi

Program cannot auto update the dimension, I need manually update the dimension.

Please help me to solve the problem.

 

;; multiply xd and yd with 1.1 so that the drawing slightly smaller than the drawing frame...
   (setq xd (* (- (car urc) (car llc)) 1.1))
   (setq yd (* (- (cadr urc) (cadr llc)) 1.1))
   ;; Set xd1 and yd1 to actual size
   (setq xd1 (- (car urc) (car llc)))
   (setq yd1 (- (cadr urc) (cadr llc)))
   (setq
     ctp (polar llc (angle llc urc) (/ (distance llc urc) 2.0))
   )

   ;; get the scale factor
   (setq xscale (/ xd tx))
   (setq yscale (/ yd ty))
   (setq x1scale (/ xd1 tx))
   (setq y1scale (/ yd1 ty))
   (if (< xscale yscale)
     (setq scale1 y1scale)
     (setq scale1 x1scale)
   )
  
          (cond
     ;; Only scale the drawing if one of the xscale or yscale is > 1..
     (if (or (> xscale 1) (> yscale 1))
       (progn
         (if (< xscale yscale)
    (setq scale yscale)
           (setq scale xscale)
         )
         (command "_.scale"
           (acadsset ssetobj)
           ""
           rt_ctp
           (/ 0.9 scale)
         )
         ;;Set dimension dimlfac according "acadsset ssetobj" scale
         (command "_DIMLFAC" (* 1.22222 scale1) "" (acadsset ssetobj))
         (command "-dimstyle" "restore" ssetobj)

       );progn
     ); if

Message 5 of 23
pbejse
in reply to: knlooi


@knlooi wrote:

Program cannot auto update the dimension, I need manually update the dimension.

Please help me to solve the problem.

 

;;


We would want to help you. but i'm not even sure if you want us to modify your code for it to owrk on your DIMLFAC issues, only thing is you posted a lisp routine with missing subs. I cant see the big picture.

 

Tell you what. imagine you dont have that lisp code. What exactly do you want to do?

treat me like a 5 year old and describe it for me. That is if you dont mind. Smiley Happy

 

 

Message 6 of 23
Kent1Cooper
in reply to: knlooi


@knlooi wrote:

Help! How to make a program that use DIMLFAC to change the dimensions according to the selected object scale factor (change selected dimension only)


If the yellow-lines thingie is a Block, and it's scaled up, and you want the linear scale factor of the dimensions scaled down so that they agree with the un-scaled-up actual size of the thingie, then you would apply the inverse of the Block scale factor to the LinearScaleFactor VLA property of the dimensions.  (You can do it with entity data, but it's more complicated, because you have to dig into extended data.)

 

This will get the X scale factor from the Block [I assume it would be uniformly scaled, so it wouldn't matter which scale factor you get]:

 

(setq blkscale (cdr (assoc 41 (entget (car (entsel "\nSelect Block to correct dimensions on it: "))))))

 

This will make a selected dimension compensate its text content for the Block's scale factor:

 

(setq dimobj (vlax-ename->vla-object (car (entsel "\nSelect Dimension to adjust: "))))

(vla-put-LinearScaleFactor dimobj (/ 1 blkscale))

 

That could be incorporated into something that would ask for a selection of multiple Dimensions, and apply the same to all of them, etc.

 

The same approach would apply whatever the Block scale is, whether larger than or smaller than [or equal to, for that matter] 1.

Kent Cooper, AIA
Message 7 of 23
knlooi
in reply to: Kent1Cooper

could you help me to modify my lisp? My problem all show in tcmr lisp file.

Lisp post next reply.

Message 8 of 23
knlooi
in reply to: knlooi

 
Message 9 of 23
Kent1Cooper
in reply to: knlooi


@knlooi wrote:

could you help me to modify my lisp? My problem all show in tcmr lisp file.

....


I'm not conversant enough in DCL to be a good source for help on this.  But seeing it makes me wonder:

 

Would it make more sense to have your sheet with its title/heading and chart/list elements in a paper-space layout rather than in model space with the part(s)?  That's really the whole point of the distinction between model space and paper space, and the sheet elements certainly are not part of the model of the object(s) -- they really are "paper" information.

 

Then you could include the part in the sheet by way of a viewport, and you would need only to set the viewing scale of that viewport to optimize the look of the part in the available area on the page.  You wouldn't need to scale the part itself, nor have it in the drawing twice, nor change DIMLFAC [either in the drawing as a whole or for any individual dimensions], nor have anything in there that's not at actual size and risk having the wrong-sized version of it copied out by somebody for another part, etc., etc.

Kent Cooper, AIA
Message 10 of 23
pbejse
in reply to: knlooi

What about this lisp?

 

(load "C:\\lsp\\data.lsp");<------

 

Still missing knlooi.  Smiley Happy

 

Message 11 of 23
dbroad
in reply to: knlooi

Knooli,

 

I would encourage you to avoid techniques to manipulate dimlfac based on scale factors.  Such techniques are simply not needed. (AutoCAD user for more than 25 years).

 

Best practice is to work on object full size and dimension them in the same space they are drawn in IMO.  If I need to have multiple scales on a single sheet, I typically work with each scale in its own drawing file and xattach the separate files into a sheet file.  Others would use several annotation scales within a single model space and use paper space for scaling the plots.

 

Another technique is to wrap the objects inside block and use bedit.  Problem with that is that bedit always resets the drawing scale to 1:1 which is annoying.

 

Others use viewports for scaling and dimension in paper space of the sheet they are plotting.

 

I prefer not to work behind others who have scaled object in model space so that dimensions and the distance command can no longer measure them.  To add information or to edit such a drawing requires checking the properties of the dimensions, finding dimlfac, scaling the objects back to full size, and then re-scaling them.

 

Good luck.

Architect, Registered NC, VA, SC, & GA.
Message 12 of 23
knlooi
in reply to: dbroad

Thanks for your reply

 

Kent& dbroad,

I don't understand how to use paper space. Normally, our full drawing have more then hundred objects, difference size of each object. If I set the viewing scale, all the pages size cannot make it standardize to keeping softcopy and hardcopy. Actually, I need to make like Inventor “Detail” command, can be scale up and scale down object, but dimension same as original object.

 

Pbejse,

Yes, I missed the data lisp.

The data lisp is use to call tooling_info.lsp, this lisp is using in other software and not is autolisp.

Attached dwg file included data information, when running tcmr.lsp will skip the data lisp.

Message 13 of 23
pbejse
in reply to: knlooi


@knlooi wrote:

Thanks for your reply

  

Pbejse,

Yes, I missed the data lisp.

The data lisp is use to call tooling_info.lsp, this lisp is using in other software and not is autolisp.

Attached dwg file included data information, when running tcmr.lsp will skip the data lisp.


**** Try the lisp routine now*****

I commented that part where i the modifed the code [see attached]
;;; <-------

I totally agree with kent and dbroad regarding scaling the drawing and using paperpsapce though
But since you already had it setup the way you had might as well help you out a little.

Cheers

 

BTW:

Take out coment tag  where you  load the data.lsp, I left it there while testing your code

 

HTH

 

Message 14 of 23
pbejse
in reply to: pbejse

As i was watching the video you posted, you mentioned there that you want the DIMLFAC value to maintain the

value of 1

 

So

.....

(progn (setvar 'Dimlfac (* 1.22222 scale1))
                       (command "_-dimstyle" "_apply" obj "")
                      (setvar 'Dimlfac 1);<----- here
                       )

......

 or here

(setvar "osmode" oosm)

(setvar 'Dimlfac 1);<----- or here

  ) (alert "User Cancel!")

.....

 

 

HTH

 

Message 15 of 23
knlooi
in reply to: pbejse

Pbejse,

Thank you very much, the lisp work is very good now.

One more question need your help is the dimension missing dia. and tolerance, can use the lisp to set it back?

Message 16 of 23
pbejse
in reply to: knlooi


@knlooi wrote:

Pbejse,

Thank you very much, the lisp work is very good now.

One more question need your help is the dimension missing dia. and tolerance, can use the lisp to set it back?


Oh that... Sure it can be done

Questions:

What other dimension properties beside Tolerance do you usually override?

Theres a long list for such, so  i need to reduce the number to a few selected properties

 

Answer those Q's then  I'll iupdate the code and get back to you

 

 

 

 


 

Message 17 of 23
pbejse
in reply to: pbejse

Easiest solution is to repalce all this

(progn (setvar 'Dimlfac (* 1.22222 scale1))
                       (command "_-dimstyle" "_apply" obj "")
                       (setvar 'Dimlfac 1)
                       )

 

to this

(command "_dimoverride" "DIMLFAC" (* 1.22222 scale1) "" obj "")

 

Try it.

Message 18 of 23
knlooi
in reply to: pbejse

Pbejse,

Thanks your help!

 

Is symmetrical and deviation.

Message 19 of 23
pbejse
in reply to: knlooi


@knlooi wrote:

Pbejse,

Thanks your help!

 


Glad I could help.

 

There's still a lot of improvement that can be done on your lisp code. Did you wirte this one yourself?  

Code after code you will understand  and learn what works and what doesnt.

 

Keep on coding knlooi

 

Cheers Smiley Happy

 

Message 20 of 23
knlooi
in reply to: pbejse

Ok, I try to write this lisp. Thanks again.

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

Post to forums  

Autodesk Design & Make Report

”Boost