Author Topic: ( C3D ) Linetypes in Model Space?  (Read 9361 times)

0 Members and 1 Guest are viewing this topic.

Dinosaur

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #15 on: December 11, 2006, 10:32:51 AM »
I can adapt certain bits of existing code if I know where to look for the changes and what to change things to.  I can find the reference to the dimscale in this code, but am lost after that point.  Could someone provide a flashlight for the greenest of lisp rookies?

b_hailey

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #16 on: December 11, 2006, 02:15:17 PM »
Thank you for making that available.  I am wondering if there is a way to do this without tying it to a dimscale.  I have drawings that contain multiple viewports of different scales and also many dimensions are in paper space, hence it is quite likely the current dimscale will not be the LTScale I need.
That routine uses the dimscale as the default ltscale for model space.  If you type tmm (I don't know why I chose that, I just did) it will bring up the settings and you can set your model space ltscale to whatever you want as well as your paperspace ltscale.

Dinosaur

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #17 on: December 11, 2006, 02:41:55 PM »
Excellent, that was the point where every other routine would fail for me.  The only one close to a solution kept messing with dimscales as well and would eventually AutoCAD would go unstable.  This one seems to work perfectly, thanks.  I was surprised to discover you were in what I remember to be a very small town where I would not have expected to find an Autodesk reseller.  I spent about 15 years in and around Thornton, CO and the closest one I knew of was in the Tech Center.  Happy things must be happening up north of Denver.  :-)

sinc

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #18 on: December 11, 2006, 02:45:36 PM »
I was surprised to discover you were in what I remember to be a very small town where I would not have expected to find an Autodesk reseller.  I spent about 15 years in and around Thornton, CO and the closest one I knew of was in the Tech Center.  Happy things must be happening up north of Denver.  :-)

How long ago was that?   :lol:

Thornton and the Tech Center are basically two areas in one big city these days...

Dinosaur

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #19 on: December 11, 2006, 02:48:29 PM »
They were back then (1977-1993) as well - just a lot of city in between them.  Frederick is several miles of what was then wheat field north of where Thornton ended.

EDIT

BTW, even though this issue seems to be solved, should anyone be interested in teaching an old dog some new tricks, I would still like to figure out how to make the changes to the routine that sinc was suggesting should a similar solution be needed for other problems, ie automatic scaling of blocks, etc.
« Last Edit: December 11, 2006, 02:54:22 PM by DinØsaur »

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: ( C3D ) Linetypes in Model Space?
« Reply #20 on: December 11, 2006, 02:54:11 PM »
It should also be possible to tie it directly to the Drawing Scale, but I'm not entirely sure how to access that...  The Civil-3D Automation documentation basically sucks right now.
Here's some help in that regard......
Code: [Select]
This will allow you to either get or set the scale...

Usage:
(get-put-dwgscale nil);;retrieves the current scale setting
(get-put-dwgscale 50.0);;sets the current scale setting to 50

No error checking provided, so make sure to pass either nil or a valid Real
number for the scale.

(defun get-put-dwgscale (scale / acadobj aecobj aecdoc)
  (if (and (setq acadobj (vlax-get-acad-object))
    (setq aecobj (vla-getinterfaceobject
     acadobj
     "AeccXUiLand.AeccApplication.4.0"
     ;;change to 3.0 for use in 2006
   )
   )
    (setq aecDoc (vla-get-activedocument aecobj))
    (setq zonesets (vlax-get
       (vlax-get
         (vlax-get aecdoc 'settings)
         'drawingsettings
         )
       'unitzonesettings))
    )
    (progn
      (if scale
 (vlax-put zonesets 'drawingscale scale)
 (setq scale (vlax-get zonesets 'drawingscale))
 )
      )
    )
  (vl-catch-all-apply '(lambda ()
   (mapcar 'vlax-release-object
    (list zonesets aecdoc aecobj acadobj))
   ))
  scale
  )

b_hailey

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #21 on: December 11, 2006, 03:51:40 PM »
I was surprised to discover you were in what I remember to be a very small town where I would not have expected to find an Autodesk reseller.  I spent about 15 years in and around Thornton, CO and the closest one I knew of was in the Tech Center.  Happy things must be happening up north of Denver.  :-)

I've been with this company for about 4 months now (and loving it).  I used to be a design engineer up in Loveland.  CommTech used to be based out of Boulder but has since moved out to Frederick.  There are now three resellers in Colorado, one in the Tech Center, one in Thornton, and us.

sinc

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #22 on: December 11, 2006, 06:03:26 PM »
I've been with this company for about 4 months now (and loving it).  I used to be a design engineer up in Loveland.  CommTech used to be based out of Boulder but has since moved out to Frederick.  There are now three resellers in Colorado, one in the Tech Center, one in Thornton, and us.

CommTech is our reseller.  We tried to get quotes from the other two, and they really dragged their heels (because we're too small?).  Commtech had us a quote later that day, I believe.  The others finally got us quotes, one roughly the same as Commtech and one significantly higher, but we had to call each of them several times in order to get the quotes.  We purchased from Commtech mainly because they were more responsive than the other two - the others really started to annoy us.

b_hailey

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #23 on: December 12, 2006, 10:31:37 AM »
sinc,

I'm glad to here you like CommTech.  Would it be OK to use what you had posted in some of our promotional literature?  It might also be a good plug for your company (sounds like a win win situation to me).  I tried to PM you but it doesn't seem to be working.  If you would like, you can send me an e-mail at brianh at ctcivil dot com

Brian

sinc

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #24 on: December 12, 2006, 12:18:00 PM »
sinc,

I'm glad to here you like CommTech.  Would it be OK to use what you had posted in some of our promotional literature?  It might also be a good plug for your company (sounds like a win win situation to me).  I tried to PM you but it doesn't seem to be working.  If you would like, you can send me an e-mail at brianh at ctcivil dot com

Brian

Sure.  Although you may want to edit it a bit...  If you included everything I said, it might start sounding like you're bashing your competition, which you may not want to do (at least, not obviously) in your promotional literature...   :-)

sinc

  • Guest
Re: ( C3D ) Linetypes in Model Space?
« Reply #25 on: March 25, 2007, 03:22:51 PM »
I've now incorporated this along with the rest of my routines.

But it's also become apparent that it's still often useful to use old-style Dimensions in Civil-3D.  That means we still have some of the same problems as in Land Desktop.

So, in addition to changing PSLTSCALE and LTSCALE as the user switches between modelspace and paperspace, it also sets the DIMSCALE to the Drawing Scale in modelspace, and DIMSCALE=0 in paperspace.  It also keeps the DIMSCALE set correctly when the user changes the DIMSTYLE in the dropdown box in the Styles toolbar.

(Note:  DIMSCALE=0 is much like DIMSCALE=1, except dimensions also scale correctly when they are created in model space through a viewport located in paperspace.  This makes DIMSCALE=0 a particularly useful setting in paperspace.  If you are confused about how to define DIMSTYLES and use DIMSCALE, you may want to read this explanation of how they work in Land Desktop.  They work in much the same way in Civil-3D, except Civil-3D has Labels instead of Text Style Sets.)

This doesn't solve all problems in Civil-3D.  Since it basically links the DIMSCALE to the DRAWING SCALE, you'll probably want to change DRAWING SCALE to match the viewport you are working on.   However, this has the unintended side-effect of causing ALL labels in modelspace to change size.  If you are creating labels that will be defined in viewports that are set to radically-different scales, this can be pretty annoying.  It's possible that I should create some other variable entirely (possibly one that works much like a system variable), and use it instead of the main Drawing Scale.  But this version works fairly well for now.

Here's the part of the C# code that works much like the Lisp in the above post:

Code: [Select]
/*
 * Created by Richard Sincovec
 * User: Sinc
 * Date: 3/25/2007
 * Time: 8:15 AM
 *
 */

using System;
using ACAD = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AECC.Interop.Land;
using Civil3DUtilities;

namespace Sincpac.Misc
{
/// <summary>
/// Contains generic reactor code.  Currently, this only contains stuff that corrects
/// various problems with DIMSCALE, LTSCALE, etc.  This command can be run from the
/// NETLOAD command while loading the DLL.
/// </summary>
public class Reactors
{
private static bool dimstyleChanged = false;
private static bool fixscalesEnabled = false;
public Reactors()
{
}

[CommandMethod("FIXSCALES")]
public void EnableFixscales()
{
if (!fixscalesEnabled) {
ACAD.Application.SystemVariableChanged += new ACAD.SystemVariableChangedEventHandler(SystemVariableChanged);
fixscalesEnabled = true;
}
}

[CommandMethod("UNFIXSCALES")]
public void DisableFixscales()
{
if (fixscalesEnabled) {
ACAD.Application.SystemVariableChanged -= new ACAD.SystemVariableChangedEventHandler(SystemVariableChanged);
fixscalesEnabled = false;
}
}

public void SystemVariableChanged(object o, ACAD.SystemVariableChangedEventArgs e)
{
try {
// Editor ed = ACAD.Application.DocumentManager.MdiActiveDocument.Editor;
// ed.WriteMessage("\nSystem Variable changed:  {0}", e.Name);
if (e.Name.Equals("TILEMODE")) {
// user changed from paperspace to modelspace or vice-versa
Database db = ACAD.Application.DocumentManager.MdiActiveDocument.Database;
if (db.TileMode == false) {
// Paperspace
db.Dimscale = 0;
db.Ltscale = 1;
db.Psltscale = true;
} else {
// Modelspace
C3DUtil c3dUtil = new C3DUtil();
double drScale = c3dUtil.AeccDb.Settings.DrawingSettings.UnitZoneSettings.DrawingScale;
db.Dimscale = drScale;
db.Ltscale = drScale;
db.Psltscale = false;
}
}
// Fix DIMSCALE.  This is a bit convoluted, but I had to do this to make it work.
// Basically, after the DIMSTYLE is changed, Autocad will attempt to reset DIMSCALE to 1.
// But it does this *after* changing the DIMSTYLE, and if the DIMSCALE is already 1, then
// it does nothing.  So, in order to get a consistent response from Autocad, we first set
// the DIMSCALE to what we want.  Autocad will then reset it to 1, at which time we again
// set the DIMSCALE to what we want.  This time it will stay.  We use the "dimstyleChanged"
// static variable to keep track of what's going on, since this event handler ends up
// being called multiple times.  End result is that DIMSCALE = DRAWING SCALE in modelspace,
// and DIMSCALE = 0 in paperspace.
if (e.Name.Equals("DIMSTYLE")) {
// this part gets run after user sets new DIMSTYLE
changeScales();
dimstyleChanged = true;
}
if (dimstyleChanged && e.Name.Equals("DIMSCALE")) {
// after Autocad resets the DIMSCALE back to 1, this part gets run
dimstyleChanged = false;
changeScales();
}
}
catch {}
}

private void changeScales()
{
Database db = ACAD.Application.DocumentManager.MdiActiveDocument.Database;
if (db.TileMode == false) {
// Paperspace
db.Dimscale = 0;
} else {
// Modelspace
C3DUtil c3dUtil = new C3DUtil();
double drScale = c3dUtil.AeccDb.Settings.DrawingSettings.UnitZoneSettings.DrawingScale;
db.Dimscale = drScale;
}
}
}
}
« Last Edit: March 25, 2007, 03:25:35 PM by sinc »