Author Topic: conversion of drawing from M to mm lisp help  (Read 2986 times)

0 Members and 1 Guest are viewing this topic.

Pad

  • Bull Frog
  • Posts: 342
conversion of drawing from M to mm lisp help
« on: December 09, 2009, 09:33:47 AM »
Hello

I have a lisp which I bolted together over some time taking bits from here and there and writing some bits myself.
It converts a drawing from metres (which we use as standard) to mm which some architects etc. insist on.
Its designed to be run once the drawing is complete, just before issue.

It scales everything in model space by 1000 using a base point of 0,0
it fixes the ltscale so that line work displays properly
changes the units precision to 0

it scales the viewport by 1000 and re-centres it.

I'd like to modify it so that it will re-scale and re-centre every viewport on every layout.
At the moment this lisp is limited to one viewport and one layout.
But I do not know how to enable this, so am hoping for some assistance please.
An extra bonus would also be to scale any dimensions appropriately as well.

I think there is a rounding error with the method of finding the viewport centre.

cheers
Pad
 

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: conversion of drawing from M to mm lisp help
« Reply #1 on: December 09, 2009, 10:05:34 AM »
I don't have time to look at the code, but you could loop through each layout and call the function .. i.e.

Code: [Select]
(setq ndx 0)
(repeat (length (layoutlist))
 (setq *acad* (vlax-get-acad-object))
 (setq *doc* (vla-get-activedocument *acad*))
 (vla-put-activelayout *doc* (vla-item (vla-get-layouts *doc*) (nth ndx (layoutlist))))
 (setq ndx (1+ ndx))
 ;;;do your layout stuff here
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Pad

  • Bull Frog
  • Posts: 342
Re: conversion of drawing from M to mm lisp help
« Reply #2 on: December 09, 2009, 12:45:01 PM »
Thanks Keith

I have some code like this:
Code: [Select]
  ;--get all layout tabs--
  (setq List_Layouts (layoutlist))
  (setq KKL 0 KLS (length List_LayOuts))
  ;--process each layout--
  (while (< KKL KLS)
    (setvar "CTAB" (nth KKL List_Layouts))
    (princ (strcat "\nProcessing '" (nth KKL List_Layouts) "' layout tab."))

do paper space stuff

    ;--get all viewports in current layout--
    (setq SSV (ssget "C" (getvar "EXTMIN") (getvar "EXTMAX") (list (cons 0 "VIEWPORT") (cons -4 "/=") (cons 69 1))))
    (setq KKV 0 KVS (sslength SSV))
    ;--process each viewport in current layout--
    (while (< KKV KVS)

do viewport stuff

tried to integrate it and failed miserably.
I'll have a play with yours when I have an hour.

Thanks
P

Pad

  • Bull Frog
  • Posts: 342
Re: conversion of drawing from M to mm lisp help
« Reply #3 on: December 11, 2009, 01:10:50 PM »
was wondering

how can I multiply the VPcenter coords
found via
(setq VPcenter (vlax-get VPobj 'Center))

by a 1000?

to then be able to feed it in to here:

          (command "ZOOM" "C" VPcenter "")

the hope is that this will take the existing viewports centre scale it up by 1000 and then re-centre it over these new coords.
The viewport scale then needs to be scaled by a 1000.

that is my next question.

i have the original viewport scale stored as a variable:

(setq VPscale (vlax-get vpobj 'customScale))

i want to scale this by a 1000, can this simply be done by?:

(setq newVPscale (* 1000 VPscale))
(vlax-put VPobj 'customscale newVPscale)

thanks
« Last Edit: December 11, 2009, 01:34:23 PM by Pad »

Crank

  • Water Moccasin
  • Posts: 1503
Re: conversion of drawing from M to mm lisp help
« Reply #4 on: December 11, 2009, 01:25:11 PM »
Be careful with scaling the viewports: Annotative entities shouldn't scale, but you've to add/change the annoscale. Also the viewport should have a new annoscale attached to it, or annotative entities will be invisible.
Vault Professional 2023     +     AEC Collection

Pad

  • Bull Frog
  • Posts: 342
Re: conversion of drawing from M to mm lisp help
« Reply #5 on: December 11, 2009, 01:31:31 PM »
Thanks Crank
At the moment i'm not worried about that, currently I don't use annotative entities.
This is purely for my own use to automate the conversion of a drawing from metres to mm, with multiple viewports and layouts.

Annotative entities are a bridge I can try to cross another day.

Pad

  • Bull Frog
  • Posts: 342
Re: conversion of drawing from M to mm lisp help
« Reply #6 on: December 14, 2009, 10:14:01 AM »
Can anybody help please?

rhino

  • Guest
Re: conversion of drawing from M to mm lisp help
« Reply #7 on: December 28, 2009, 03:21:06 PM »
I don't have time to look at the code, but you could loop through each layout and call the function .. i.e.

Code: [Select]
(setq ndx 0)
(repeat (length (layoutlist))
 (setq *acad* (vlax-get-acad-object))
 (setq *doc* (vla-get-activedocument *acad*))
 (vla-put-activelayout *doc* (vla-item (vla-get-layouts *doc*) (nth ndx (layoutlist))))
 (setq ndx (1+ ndx))
 ;;;do your layout stuff here
)

You just need to modularize your code into individual functions & call each after where keith put the ;;;

Also you need some error trapping to locate the problematic code.

Could you attach a dwg file with the layouts & viewports to test on.

rhino

  • Guest
Re: conversion of drawing from M to mm lisp help
« Reply #8 on: December 28, 2009, 03:26:38 PM »
another alternate would be if you could get the coordinates of the viewport in paper space and the corresponding coordinates in model space and then just scale those values by a 1000.

Pad

  • Bull Frog
  • Posts: 342
Re: conversion of drawing from M to mm lisp help
« Reply #9 on: January 04, 2010, 09:36:22 AM »
Hello Rhino

Thanks for the reply and sorry for the delay in getting back to you.
I have been trying to sort this out for a while now and just get stuck each time.
Attached are a couple of drawings in before and after states.

Thanks
Pad